OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [g++.old-deja/] [g++.brendan/] [copy6.C] - Blame information for rev 749

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 699 jeremybenn
// { 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
20
 
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
25
 
26
*/
27
 
28
extern "C" int printf (const char *, ...);
29
extern "C" void exit (int);
30
 
31
int count = 0;
32
 
33
void die () { printf ("FAIL\n"); exit (1); }
34
 
35
struct test {
36
        test() { if (count != 0) die (); }
37
 
38
        test(unsigned) {
39
          die ();
40
        }
41
        operator unsigned() {
42
          die ();
43
          return 0;
44
        }
45
};
46
 
47
int
48
main() {
49
  test k;
50
  test l=k;
51
 
52
  printf ("PASS\n");
53
 
54
  return 0;
55
}
56
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.