PR c++/12253
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 18 Dec 2003 21:03:42 +0000 (21:03 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 18 Dec 2003 21:03:42 +0000 (21:03 +0000)
        * init.c (build_vec_init): Initialization of an element from
        an initializer list is also a full-expression.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@74798 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/testsuite/g++.dg/init/array12.C [new file with mode: 0644]

diff --git a/gcc/testsuite/g++.dg/init/array12.C b/gcc/testsuite/g++.dg/init/array12.C
new file mode 100644 (file)
index 0000000..3bb4800
--- /dev/null
@@ -0,0 +1,28 @@
+// PR c++/12253
+// Bug: We were failing to destroy the temporary A passed to the
+// constructor for b[0] before going on to construct b[1].
+
+// { dg-do run }
+
+extern "C" int printf (const char *, ...);
+
+int c;
+int r;
+
+struct A
+{
+  A() { printf ("A()\n"); if (c++) r = 1; }
+  A(const A&) { printf ("A(const A&)\n"); ++c; }
+  ~A() { printf ("~A()\n"); --c; }
+};
+struct B
+{
+  B(int, const A& = A()) { printf ("B()\n"); }
+};
+int main()
+{
+  B b[] = { 0, 0 };
+  return r;
+}