home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / gnu / gcc / bug / 3224 < prev    next >
Encoding:
Text File  |  1993-01-21  |  1.6 KB  |  49 lines

  1. Path: sparky!uunet!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!cis.ohio-state.edu!nlr.NL!hogend
  2. From: hogend@nlr.NL (hogendoorn r.a.)
  3. Newsgroups: gnu.gcc.bug
  4. Subject: gcc 2.3.3 bug or feature ?
  5. Date: 21 Jan 1993 18:13:31 -0500
  6. Organization: GNUs Not Usenet
  7. Lines: 36
  8. Sender: daemon@cis.ohio-state.edu
  9. Approved: bug-gcc@prep.ai.mit.edu
  10. Distribution: gnu
  11. Message-ID: <9301211437.AA02806@uxmain.nlr.nl>
  12.  
  13. The problem concerns the inlining of 'friend' functions declared inside 
  14. class scope. 
  15. If optimization is turned off, no inlining takes place. The generated
  16. procedures, however, are 'static' so they cannot be referenced outside
  17. file scope. At least, this was the situation with gcc 2.2.2.
  18. With gcc 2.3.3, this no longer holds true for 'friend' functions,
  19. declared inside class scope. These generate procedures that are globally
  20. visible and generate, for instance, 'ld' and 'ar' warnings "ignoring second
  21. definition of <bwurp> in archive" if the class declaration is used in
  22. more than one source file.
  23. Obviously, the problem disappears if optimization is turned on, but it also
  24. disappears if the 'friend' function is explicitly qualified 'inline'.
  25. According to ARM, the qualification is not needed.
  26.  
  27. The compiler is gcc 2.3.3 [MM 33] installed with mips-sysv on a MIPS
  28. running RISCos4.0.
  29.  
  30. A simple example:
  31.  
  32. class X {
  33.     int xvalue;
  34. public:
  35.     X () : xvalue (0) {};
  36.     X (const int i) : xvalue (i) {};
  37.  
  38.     int value () const {return xvalue;};
  39.  
  40.     X operator * (const int i) const {return X (xvalue * i);};
  41.  
  42. // and this one causes the trouble
  43.  
  44.     friend X operator * (const int i, const X x) {return x * i;};
  45. };
  46.  
  47. regards, Rene Hogendoorn
  48.  
  49.