Article View: gnu.gcc.bug
Article #1633gcc 2.3.3 bug or feature ?
From: hogendoorn r.a.
Date: Thu, 21 Jan 1993 23:13
Date: Thu, 21 Jan 1993 23:13
35 lines
1681 bytes
1681 bytes
The problem concerns the inlining of 'friend' functions declared inside
class scope.
If optimization is turned off, no inlining takes place. The generated
procedures, however, are 'static' so they cannot be referenced outside
file scope. At least, this was the situation with gcc 2.2.2.
With gcc 2.3.3, this no longer holds true for 'friend' functions,
declared inside class scope. These generate procedures that are globally
visible and generate, for instance, 'ld' and 'ar' warnings "ignoring second
definition of <bwurp> in archive" if the class declaration is used in
more than one source file.
Obviously, the problem disappears if optimization is turned on, but it also
disappears if the 'friend' function is explicitly qualified 'inline'.
According to ARM, the qualification is not needed.
The compiler is gcc 2.3.3 [MM 33] installed with mips-sysv on a MIPS
running RISCos4.0.
A simple example:
class X {
int xvalue;
public:
X () : xvalue (0) {};
X (const int i) : xvalue (i) {};
int value () const {return xvalue;};
X operator * (const int i) const {return X (xvalue * i);};
// and this one causes the trouble
friend X operator * (const int i, const X x) {return x * i;};
};
regards, Rene Hogendoorn
Technical Details
Message-ID:
<9301211437.AA02806@uxmain.nlr.nl>Path:
arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!cis.ohio-state.edu!nlr.NL!hogendShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!cis.ohio-state.edu!nlr.NL!hogend From: hogend@nlr.NL (hogendoorn r.a.) Newsgroups: gnu.gcc.bug Subject: gcc 2.3.3 bug or feature ? Date: 21 Jan 1993 18:13:31 -0500 Organization: GNUs Not Usenet Lines: 36 Sender: daemon@cis.ohio-state.edu Approved: bug-gcc@prep.ai.mit.edu Distribution: gnu Message-ID: <9301211437.AA02806@uxmain.nlr.nl>