]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
c++: constexpr array testcase [PR87097]
authorJason Merrill <jason@redhat.com>
Thu, 17 Jul 2025 13:46:35 +0000 (09:46 -0400)
committerJason Merrill <jason@redhat.com>
Thu, 17 Jul 2025 14:05:01 +0000 (10:05 -0400)
This seems to have been fixed by r15-7260 for PR118285, but is sufficiently
different to merit its own test.

PR c++/87097

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/constexpr-array29.C: New test.

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

diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-array29.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-array29.C
new file mode 100644 (file)
index 0000000..714d050
--- /dev/null
@@ -0,0 +1,13 @@
+// PR c++/87097
+// { dg-do compile { target c++11 } }
+
+struct A {
+  constexpr A() : data() {}
+  struct X { int n; };
+  X data[2];
+};
+
+static_assert((A(), true), "");
+static_assert(A().data[0].n == 0, "");
+static_assert(A().data[1].n == 0, "");
+constexpr A x;