c++: Add test for Core issue 1376 [PR52202]
authorMarek Polacek <polacek@redhat.com>
Wed, 7 Apr 2021 02:17:33 +0000 (22:17 -0400)
committerMarek Polacek <polacek@redhat.com>
Wed, 7 Apr 2021 02:18:17 +0000 (22:18 -0400)
As Jens says in the PR, we handle this correctly.

gcc/testsuite/ChangeLog:

PR c++/52202
* g++.dg/cpp0x/rv-life.C: New test.

gcc/testsuite/g++.dg/cpp0x/rv-life.C [new file with mode: 0644]

diff --git a/gcc/testsuite/g++.dg/cpp0x/rv-life.C b/gcc/testsuite/g++.dg/cpp0x/rv-life.C
new file mode 100644 (file)
index 0000000..0fd1119
--- /dev/null
@@ -0,0 +1,12 @@
+// Core 1376
+// PR c++/52202
+// { dg-do run { target c++11 } }
+
+extern "C" void abort();
+bool x;
+struct T { ~T() { if (!x) abort (); } };
+int main()
+{
+  T&& r = static_cast<T&&>(T());
+  x = true;
+}