[C++] friend et fatal error C1001: INTERNAL COMPILER ERROR

friend et fatal error C1001: INTERNAL COMPILER ERROR [C++] - Programmation

Marsh Posté le 23-09-2001 à 20:14:59    

Avec un titre comme ca, si y a personne qui lit mon topic, c'est que y a un grave prb !! :)
 
Alors mon prb est tout con...Je suis sous Visual C++ 6.0 (sans service pack), j'ai une classe nommée HugeImplem qui contient les 2 declarations des fonctions friend suivantes:
 
friend ostream& operator << (ostream&, HugeImplem&);
friend HugeImplem operator + (const HugeImplem&, const HugeImplem&);
 
La premiere est implementée plus loin (même fichier), normalement, comme suit:
ostream& operator << (ostream& out, HugeImplem& toshow);
{
   out << toshow.m_adr;
   return out;
}
 
La seconde est implementée aussi plus loin dans le meme fichier...
 
Et j'ai 2 types d'erreur:
- Pour la surdefinition de << j'ai :
error C2248: 'm_adr' : cannot access private member declared in class 'HugeImplem'
 
Pourtant elle est déclaré en ami, non??
 
- Et le plus joli, pour la deuxieme fonction j'ai un extraordinaire :
fatal error C1001: INTERNAL COMPILER ERROR
 
au moment de la declaration....
 
Bon...je peux pas installer le SP5 chez moi, vu le niveau de la connection. Je vais m'en aller verifier si c'est un prb connu.

 

[edtdd]--Message édité par willythekid--[/edtdd]

Reply

Marsh Posté le 23-09-2001 à 20:14:59   

Reply

Marsh Posté le 23-09-2001 à 20:38:10    

vire deja le ; a la fin de  
ostream& operator << (ostream& out, HugeImplem& toshow);  
{  
  out << toshow.m_adr;  
  return out;  
}  
 
ta classe HugeImplem c'est un template ?

Reply

Marsh Posté le 23-09-2001 à 20:49:27    

Ah oui heu merde :)
 
Heu non même pas...C'est une petite classe qui contient une chaine de caractere (char* m_adr) et pas mal d'autres membres dynamiques...Rien de transcendant !!
C'est une classe de stockage qui sert de wrappeur autour d'une librairie en C.
 
Bon apparement y a pas mal de bug avec ce C1001, je vais downloader le SP demain...


---------------
Si t'es pas net, reste a la buvette
Reply

Marsh Posté le 23-09-2001 à 20:55:42    

je suis pas sur qu'en mettant le sp5 ca va virer les internal error. J'en ai deja eu et c'est parce que le compilo n'aimait pas ma facon de coder  :D, mets un peu plus de code....

Reply

Marsh Posté le 23-09-2001 à 20:57:33    

Ok, le 2eme probleme est reglé!
 
FIX: 'using namespace std' Before Friend Operator Fails Compile
 
The information in this article applies to:
 Microsoft Visual C++, 32-bit Enterprise Edition, version 6.0  
 Microsoft Visual C++, 32-bit Professional Edition, version 6.0  
 Microsoft Visual C++, 32-bit Learning Edition, version 6.0
 
   SYMPTOMS
   When a "using namespace std" directive is placed before a friend operator declaration, you may get one of the following two errors:  
 
   Case 1
   error C2248: [member variable name] : cannot access private member declared in class
   [class name] [file name] (line number) : see declaration of [member variable]  
 
   Case 2
   [file name](line number) : fatal error C1001: INTERNAL COMPILER ERROR
   (compiler file 'msc1.cpp', line 1786)
   Please choose the Technical Support command on the Visual C++ Help menu, or open the Technical Support help file for more information.
   Error executing cl.exe.  
 
 
   CAUSE
   The friend operator resolution fails in the compiler front-end when std namespace is introduced.  
 
   RESOLUTION
   A supported fix is now available from Microsoft, but it is only intended to correct the problem described in this article and should be applied only to systems experiencing this specific problem. This fix may receive additional testing at a later time, to further ensure product quality. Therefore, if you are not severely affected by this problem, Microsoft recommends that you wait for the next Service Pack 3 for Visual Studio 6.0 that contains this fix.
 
   To resolve this problem immediately, contact Microsoft Product Support Services to obtain the fix. For a complete list of Microsoft Product Support Services phone numbers and information about support costs, please go to the following address on the World Wide Web:
 
   NOTE: In special cases, charges that are normally incurred for support calls may be canceled, if a Microsoft Support Professional determines that a specific update will resolve your problem. Normal support costs will apply to additional support questions and issues that do not qualify for the specific update in question.  
 
   The English version of this fix should have the following file attributes or later:
 
      Date      Time      Size        File Name  Version#      Platform
      -----------------------------------------------------------------
 
      9/15/98   08:26p    1,183,795   C1xx.dll   12.00.8257.0  (x86)  
 
 
   Workaround
 
   Do one of the following to work around this problem:  
 
   Move the "using namespace std" directive after the friend operator declaration.  
   Avoid using the "using namespace std" directive.  
   Forward declare the operator and/or class.  
 
 
   STATUS
 
   Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article.This bug was corrected in Visual Studio 6.0 Service Pack 3. For more information about Visual Studio service packs, please see the following articles in the Microsoft Knowledge Base:
 
   Q194022 INFO: Visual Studio 6.0 Service Packs, What, Where, Why
   Q194295 HOWTO: Tell That Visual Studio 6.0 Service Packs Are Installed
 
 
   MORE INFORMATION
   Test1.cpp Reproduces the C2248 Error in Case 1
 
      // test1.cpp
      // Compiler options needed: cl /c /GX
      #include <iostream>
 
      using namespace std;
 
      #ifdef WORKAROUND
      class CMyClass;
      ostream& operator <<(ostream &, const CMyClass &);
      #endif // WORKAROUND
 
      class CMyClass
      {
      public:
 
        friend ostream& operator <<(ostream &, const CMyClass &);
        // An alternative workaround is to define the operator in the
        // class declaration. In this case it is not necessary to forward
        // declare the class and friend function.
 
      private:
 
         int value;
      };
 
      ostream& operator <<(ostream& out, const CMyClass& m)
      {
 
         int i = m.value;  // C2248 Error
         return out;
      }
 
      void main()
      { }  
 
   Test2.cpp Reproduces the C1001 Error in Case 2
 
      // test2.cpp
      // Compiler options needed: cl /c /GX
      #include <iostream>
 
      using namespace std;
 
      #ifdef WORKAROUND
      int operator+(int, const class &);
      #endif // WORKAROUND
 
      class CMyClass
      {
      public:
 
        friend int operator+(int, const CMyClass &);  // C1001 Error.
 
      };
 
      void main()
      { }


---------------
Si t'es pas net, reste a la buvette
Reply

Marsh Posté le 23-09-2001 à 21:05:32    

Ahahah est je viens de régler mon premier probleme...Je crois qu'il faut vraiment que j'installe le service pack 5...Ca urge !! :)
 
Merci aqwsezsxdr
 
FIX: Cannot Access Private Member from Friend Class
 
The information in this article applies to:
 
The C/C++ Compiler (CL.EXE), included with:
   Microsoft Visual C++ for Windows, 16-bit edition, versions 1.0, 1.5  
   Microsoft Visual C++, 32-bit Editions, version 1.0
 
 
 
   SYMPTOMS
 
   When compiling the code below, the C/C++ compiler will incorrectly report the following error:  
   C2248: 'ptr' : cannot access private member declared in class 'X'  
 
 
   STATUS
   Microsoft has confirmed this to be a bug in the products listed at the beginning of this article. This problem was corrected in Visual C++ version 2.0.  
 
 
   MORE INFORMATION
   The following sample can be used to demonstrate this problem.  
 
   Sample Code
 
   /* Compile options needed: none
   */  
 
   #include <iostream.h>
   class C
   {
      class X;
      class Y;
 
      class X
      {
         X* ptr;
         friend Y;
      };
 
      class Y
      {
         X* x;
       public:
         X* lookat() { return x->ptr; }           /* Error: C2248 */  
      };
   };
   void main( void )
   {
      cout << "PASSED" << endl;
   }


---------------
Si t'es pas net, reste a la buvette
Reply

Marsh Posté le 23-09-2001 à 21:08:23    

autant pour moi :). Mes internal compiler error etaient dus à une utilisation pas tres catholique des templates.

Reply

Sujets relatifs:

Leave a Replay

Make sure you enter the(*)required information where indicate.HTML code is not allowed