summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.old-deja/g++.brendan/copy6.C
diff options
context:
space:
mode:
authorupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
committerupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
commit554fd8c5195424bdbcabf5de30fdc183aba391bd (patch)
tree976dc5ab7fddf506dadce60ae936f43f58787092 /gcc/testsuite/g++.old-deja/g++.brendan/copy6.C
downloadcbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.bz2
cbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.xz
obtained gcc-4.6.4.tar.bz2 from upstream website;upstream
verified gcc-4.6.4.tar.bz2.sig; imported gcc-4.6.4 source tree from verified upstream tarball. downloading a git-generated archive based on the 'upstream' tag should provide you with a source tree that is binary identical to the one extracted from the above tarball. if you have obtained the source via the command 'git clone', however, do note that line-endings of files in your working directory might differ from line-endings of the respective files in the upstream repository.
Diffstat (limited to 'gcc/testsuite/g++.old-deja/g++.brendan/copy6.C')
-rw-r--r--gcc/testsuite/g++.old-deja/g++.brendan/copy6.C56
1 files changed, 56 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/copy6.C b/gcc/testsuite/g++.old-deja/g++.brendan/copy6.C
new file mode 100644
index 000000000..8e1513190
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.brendan/copy6.C
@@ -0,0 +1,56 @@
+// { dg-do run }
+// GROUPS passed copy-ctors
+/*
+g++ 2.3.3 will prefer using type conversions over the
+implicitly generated copy constructor. This is wrong.
+If you explicitly define a copy constructor, it will
+use it. However, the implicit copy constructor MUST be
+called whenever an explicit one would have been called
+also. See below: g++ converts from and back into
+unsigned, instead of using the implicit copy constructor:
+here is the version:
+Reading specs from /usr/lib/gcc-lib/i386-linux/2.3.3/specs
+gcc version 2.3.3
+ /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
+GNU CPP version 2.3.3 (80386, BSD syntax)
+ /usr/lib/gcc-lib/i386-linux/2.3.3/cc1plus /usr/tmp/cca02008.i -quiet -dumpbase bug2.cc -version -o /usr/tmp/cca02008.s
+GNU C++ version 2.3.3 (80386, BSD syntax) compiled by GNU C version 2.3.3.
+ as -o /usr/tmp/cca020081.o /usr/tmp/cca02008.s
+ ld /usr/lib/crt0.o -nojump -L/usr/lib/gcc-lib/i386-linux/2.3.3 /usr/tmp/cca020081.o -lg++ -lgcc -lc -lgcc
+
+Ok, and here is the output:
+test k: constructing from scratch
+test l=k: type conversion into unsigned
+constructing from unsigned
+
+*/
+
+extern "C" int printf (const char *, ...);
+extern "C" void exit (int);
+
+int count = 0;
+
+void die () { printf ("FAIL\n"); exit (1); }
+
+struct test {
+ test() { if (count != 0) die (); }
+
+ test(unsigned) {
+ die ();
+ }
+ operator unsigned() {
+ die ();
+ return 0;
+ }
+};
+
+int
+main() {
+ test k;
+ test l=k;
+
+ printf ("PASS\n");
+
+ return 0;
+}
+