Article View: gnu.g++.bug
Article #1037Type conversion and overloading bugs in 2.2.2
From: Robert Mecklenburg
Date: Thu, 08 Oct 1992 10:33
Date: Thu, 08 Oct 1992 10:33
43 lines
2143 bytes
2143 bytes
Does anyone have any wisdom on the following two g++ 2.2.2 problems?
Problem 1:
gnu-bug2.c:
// gnu-bug2.c: In function `int bazz ()':
// gnu-bug2.c:12: undefined Estr operator & ()
// gnu-bug2.c:12: warning: control reaches end of non-void function
enum E { a, b, c };
struct Estr {
E value;
Estr() {}
Estr( int i ) : value( (E)i ) {}
operator E() { return value; }
};
extern Estr baz();
int bazz() { return baz() & 2; }
Here g++ fails to invoke "Estr::operator E" to convert an instance
of the class Estr to an enum. I believe the ARM indicates that
one user-defined conversion and one automatic conversion will take
place to try and satisfy an expression. In any case, this code
compiles under the AT&T (2.0, 2.1, 3.0.1), SGI, MIPS, HP, and IBM
C++ compilers.
Problem 2:
gnu-bug3.c:
// gnu-bug3.c: In function `char * index (char *, char)':
// gnu-bug3.c:6: conflicting types for `char * index (char *, char)'
// gnu-bug3.c:5: previous declaration of
// `char * index (const char *, char)'
extern "C" char *index( const char *, char );
inline char *index( char *, char ) { return 0; }
Here g++ does not allow overloading an 'extern "C"' function with
a C++ function which differs only in a const argument. The ARM
indicates that overloading on const is legal and that 'extern "C"'
functions should not prevent other overloaded versions. In any
case, this code compiles under the AT&T (2.0, 2.1, 3.0.1), SGI,
MIPS, HP, and IBM C++ compilers.
Thanks,
Robert Mecklenburg
University of Utah
Technical Details
Message-ID:
<9210082233.AA28203@hellgate.utah.edu>Path:
arc1-ca.pugleaf.net!sparky!uunet!cs.utexas.edu!sun-barr!ames!elroy.jpl.nasa.gov!swrinde!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!oops.cs.utah.edu!mecklenShow Full Headers
Complete Article Headers
Newsgroups: gnu.g++.bug Path: arc1-ca.pugleaf.net!sparky!uunet!cs.utexas.edu!sun-barr!ames!elroy.jpl.nasa.gov!swrinde!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!oops.cs.utah.edu!mecklen From: mecklen@oops.cs.utah.edu (Robert Mecklenburg) Subject: Type conversion and overloading bugs in 2.2.2 Message-ID: <9210082233.AA28203@hellgate.utah.edu> Sender: gnulists@ai.mit.edu Organization: University of Utah CS Dept Distribution: gnu Date: Thu, 8 Oct 1992 10:33:08 GMT Approved: bug-g++@prep.ai.mit.edu Lines: 44