home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / gnu / g / bug / 1849 < prev    next >
Encoding:
Text File  |  1992-11-20  |  1.3 KB  |  65 lines

  1. Newsgroups: gnu.g++.bug
  2. Path: sparky!uunet!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!efi.sintef.NO!jr
  3. From: jr@efi.sintef.NO (Jarand Roeynstrand)
  4. Subject: Scope operator bug.
  5. Message-ID: <1992Nov20.090109.22968@ugle.unit.no>
  6. Sender: gnulists@ai.mit.edu
  7. Organization: SINTEF EFI
  8. Distribution: gnu
  9. Date: Fri, 20 Nov 1992 09:01:09 GMT
  10. Approved: bug-g++@prep.ai.mit.edu
  11. Lines: 52
  12.  
  13. I usually use a cfront compiler, but suddenly i decided to run some code 
  14. through a g++ compiler as a portability test. I got the following problem:
  15. Consider the code:
  16.  
  17. class a
  18. {
  19.     public:
  20.     int x;
  21.     void SetX( int xi ) { x=xi; }
  22. };
  23.  
  24. class b
  25. {
  26.     public:
  27.     a y;
  28.     void SetY( a *y );
  29. };
  30.  
  31. void b :: SetY( a *y )
  32. {
  33.  
  34. #ifndef gcc
  35.     b :: y.SetX( y->x ); // This code does not compile under gcc. Line 20.
  36. #else
  37.     this->y.SetX( y->x );  // This code compiles under both compilers.
  38. #endif
  39.  
  40. }
  41.  
  42. The problem is, of course,that the parameter called y hides b's the member
  43. object y, and that problem is resolved by the notation b::y, only that this
  44. does not work on gcc.
  45.  
  46. gcc-2.3.1 complains:
  47.  
  48. testing.C: In method `void  b::SetY (class a*)':
  49. testing.C:20: object in '.' expression is not of aggregate type.
  50.  
  51. This seems to be a compiler bug.
  52.  
  53.  
  54. -- 
  55.     Jarand Roeynstrand            Phone:     +47-7-597275 (EFI)
  56.     EFI                        +47-7-962355 (Home)
  57.     N-7034 Trondheim        
  58.     Norway                    email: jr@efi.sintef.no
  59.     
  60.     
  61.         
  62.  
  63.     
  64.  
  65.