2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / gcc / testsuite / g++.old-deja / g++.brendan / copy6.C
blob8e15131901525c05854839bb63679e8d7ad46dc9
1 // { dg-do run  }
2 // GROUPS passed copy-ctors
3 /*
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:
11 here is the version:
12 Reading specs from /usr/lib/gcc-lib/i386-linux/2.3.3/specs
13 gcc version 2.3.3
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);
31 int count = 0;
33 void die () { printf ("FAIL\n"); exit (1); }
35 struct test {
36         test() { if (count != 0) die (); }
38         test(unsigned) {
39           die ();
40         }
41         operator unsigned() {
42           die ();
43           return 0;
44         }
47 int
48 main() {
49   test k;
50   test l=k;
52   printf ("PASS\n");
54   return 0;