aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2020-01-10 13:47:02 -0500
committerJason Merrill <jason@gcc.gnu.org>2020-01-10 13:47:02 -0500
commite0804c9b5efdf17bbfb692a787df36b86f71af8d (patch)
tree85f98decaabbf13fa0629a17b3dd0716131067bb /gcc/testsuite
parent640b23d7ff5f3fad005dcbfb04a36e27000fc150 (diff)
downloadgcc-e0804c9b5efdf17bbfb692a787df36b86f71af8d.zip
gcc-e0804c9b5efdf17bbfb692a787df36b86f71af8d.tar.gz
gcc-e0804c9b5efdf17bbfb692a787df36b86f71af8d.tar.bz2
PR c++/93143 - incorrect tree sharing with constexpr.
We don't unshare CONSTRUCTORs as often during constexpr evaluation, so we need to unshare them here. * constexpr.c (cxx_eval_outermost_constant_expr): Don't assume CONSTRUCTORs are already unshared. From-SVN: r280127
Diffstat (limited to 'gcc/testsuite')
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/constexpr-array22.C27
1 files changed, 27 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-array22.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-array22.C
new file mode 100644
index 0000000..80e24e2
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-array22.C
@@ -0,0 +1,27 @@
+// PR c++/93143
+// { dg-do run { target c++11 } }
+
+struct A { char a[2]; };
+
+static constexpr A foo () { return A{1}; }
+
+void bar ()
+{
+ A a = foo ();
+ if (a.a[0] != 1)
+ __builtin_abort();
+}
+
+void foobar ()
+{
+ A x[] = { foo (), foo () };
+ A a = foo ();
+ if (a.a[0] != 1)
+ __builtin_abort();
+}
+
+int main()
+{
+ bar();
+ foobar();
+}