aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2022-04-13 12:44:54 -0400
committerJason Merrill <jason@redhat.com>2022-04-13 20:22:18 -0400
commit019d6d4149ee97d55ce9efe4e5e470d38130cdeb (patch)
tree71ee28ed92ae60c3228c590ad36865ff303f097e
parent247bbed1b8a63201b39714bb705a9d75cbba0090 (diff)
downloadgcc-019d6d4149ee97d55ce9efe4e5e470d38130cdeb.zip
gcc-019d6d4149ee97d55ce9efe4e5e470d38130cdeb.tar.gz
gcc-019d6d4149ee97d55ce9efe4e5e470d38130cdeb.tar.bz2
c++: add test [PR105265]
This was fixed by r12-1165, but good to have a test that doesn't need -fno-elide-constructors. PR c++/105265 PR c++/100838 gcc/testsuite/ChangeLog: * g++.dg/cpp0x/initlist-new6.C: New test.
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/initlist-new6.C39
1 files changed, 39 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist-new6.C b/gcc/testsuite/g++.dg/cpp0x/initlist-new6.C
new file mode 100644
index 0000000..0ef2780
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/initlist-new6.C
@@ -0,0 +1,39 @@
+// PR c++/105265
+// { dg-do run { target c++11 } }
+
+int c;
+
+class Block
+{
+public:
+ Block(int n) : data{new char[n]}, size{n}
+ {
+ ++c;
+ }
+
+ ~Block()
+ {
+ --c;
+ delete[] data;
+ }
+
+private:
+ char* data;
+ int size;
+};
+
+struct Cargo
+{
+ Block const& block;
+};
+
+int main()
+{
+ {
+ Cargo* c = new Cargo{{4000}};
+ delete c;
+ }
+ if (c != 0)
+ __builtin_abort ();
+ return 0;
+}