[C++ COMMITTED] Add test for c++/92058

Marek Polacek polacek@redhat.com
Fri Nov 8 21:38:00 GMT 2019


Another test for the constinit issue I fixed recently (c++/92134).

Tested on x86_64-linux, applying to trunk.

2019-11-08  Marek Polacek  <polacek@redhat.com>

	PR c++/92058 - constinit malfunction in static data member.
	* g++.dg/cpp2a/constinit15.C: New test.

diff --git gcc/testsuite/g++.dg/cpp2a/constinit15.C gcc/testsuite/g++.dg/cpp2a/constinit15.C
new file mode 100644
index 00000000000..32594334330
--- /dev/null
+++ gcc/testsuite/g++.dg/cpp2a/constinit15.C
@@ -0,0 +1,14 @@
+// PR c++/92058 - constinit malfunction in static data member.
+// { dg-do compile { target c++2a } }
+
+struct B {
+    B() {}
+};
+
+struct A {
+    constinit static inline B b1{}; // { dg-error "does not have a constant initializer|call to non-.constexpr. function" }
+};
+
+int main() {
+    A a;
+}



More information about the Gcc-patches mailing list