2 // GROUPS passed copy-ctors
4 g++ 2.3.3 will prefer using type conversions over the
5 implicitly generated copy constructor. This is wrong.
6 If you explicitly define a copy constructor, it will
7 use it. However, the implicit copy constructor MUST be
8 called whenever an explicit one would have been called
9 also. See below: g++ converts from and back into
10 unsigned, instead of using the implicit copy constructor:
12 Reading specs from /usr/lib/gcc-lib/i386-linux/2.3.3/specs
14 /usr/lib/gcc-lib/i386-linux/2.3.3/cpp -lang-c++ -v -undef -D__GNUC__=2 -D__GNUG__=2 -D__cplusplus -Dunix -Di386 -Dlinux -D__unix__ -D__i386__ -D__linux__ -D__unix -D__i386 -D__linux bug2.cc /usr/tmp/cca02008.i
15 GNU CPP version 2.3.3 (80386, BSD syntax)
16 /usr/lib/gcc-lib/i386-linux/2.3.3/cc1plus /usr/tmp/cca02008.i -quiet -dumpbase bug2.cc -version -o /usr/tmp/cca02008.s
17 GNU C++ version 2.3.3 (80386, BSD syntax) compiled by GNU C version 2.3.3.
18 as -o /usr/tmp/cca020081.o /usr/tmp/cca02008.s
19 ld /usr/lib/crt0.o -nojump -L/usr/lib/gcc-lib/i386-linux/2.3.3 /usr/tmp/cca020081.o -lg++ -lgcc -lc -lgcc
21 Ok, and here is the output:
22 test k: constructing from scratch
23 test l=k: type conversion into unsigned
24 constructing from unsigned
28 extern "C" int printf (const char *, ...);
29 extern "C" void exit (int);
33 void die () { printf ("FAIL\n"); exit (1); }
36 test() { if (count != 0) die (); }