home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!cis.ohio-state.edu!cse.ucsc.EDU!dlong
- From: dlong@cse.ucsc.EDU (Dean R. E. Long)
- Newsgroups: gnu.g++.bug
- Subject: "trivial conversion" bug
- Date: 25 Jan 1993 20:05:03 -0500
- Organization: University of California, Santa Cruz (CE/CIS Boards)
- Lines: 53
- Sender: daemon@cis.ohio-state.edu
- Approved: bug-g++@prep.ai.mit.edu
- Distribution: gnu
- Message-ID: <1jr08eINNh2u@darkstar.UCSC.EDU>
-
- In this example, should not the trivial conversion (const T --> const T &)
- be applied before the user-defined conversion?
-
- --
- arapaho /tmp [61] % cat a.c
- #include <stream.h>
-
- class A {
- public:
- A(int) {}
- operator const A & (void) const
- {
- cout << "Converted to (const A &) !\n";
- return *this;
- }
- operator == (const A &a) const
- {
- return 1;
- }
- };
-
- main()
- {
- const A a = 0, b = 0;
-
- return a == b;
- }
- arapaho /tmp [62] % g++ -v a.c
- Reading specs from /usr/local/gnu/lib/gcc-lib/sparc-sun-sunos4.1.2/2.3.3/specs
- gcc version 2.3.3
- /usr/local/gnu/lib/gcc-lib/sparc-sun-sunos4.1.2/2.3.3/cpp -lang-c++ -v -undef -
- D__GNUC__=2 -D__GNUG__=2 -D__cplusplus -Dsparc -Dsun -Dunix -D__sparc__ -D__sun_
- _ -D__unix__ -D__sparc -D__sun -D__unix a.c /usr/tmp/cca19255.i
- GNU CPP version 2.3.3 (sparc)
- /usr/local/gnu/lib/gcc-lib/sparc-sun-sunos4.1.2/2.3.3/cc1plus /usr/tmp/cca19255
- .i -quiet -dumpbase a.cc -version -o /usr/tmp/cca19255.s
- GNU C++ version 2.3.3 (sparc) compiled by GNU C version 2.3.3.
- as -o /usr/tmp/cca192551.o /usr/tmp/cca19255.s
- /usr/local/gnu/lib/gcc-lib/sparc-sun-sunos4.1.2/2.3.3/ld -e start -dc -dp /lib/
- crt0.o -L/usr/local/gnu/lib/gcc-lib/sparc-sun-sunos4.1.2/2.3.3 -L/usr/local/gnu/
- lib /usr/tmp/cca192551.o -lg++ -lgcc -lc -lgcc
- arapaho /tmp [63] % a.out
- Converted to (const A &) !
- Converted to (const A &) !
- Converted to (const A &) !
- Converted to (const A &) !
- Converted to (const A &) !
- Converted to (const A &) !
- Converted to (const A &) !
- Converted to (const A &) !
- Converted to (const A &) !
- [repeated forever...]
-
-