re PR c++/89285 (ICE after casting the this pointer in the constructor in C++17 mode)
authorJakub Jelinek <jakub@redhat.com>
Mon, 25 Feb 2019 15:01:01 +0000 (16:01 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Mon, 25 Feb 2019 15:01:01 +0000 (16:01 +0100)
PR c++/89285
* g++.dg/cpp1y/constexpr-89285-2.C: New test.

From-SVN: r269188

gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp1y/constexpr-89285-2.C [new file with mode: 0644]

index bbe27aa83a6e3919960b38be699b6612cbcb7d6f..70abccc4d1af83bb52e207ea6c530d3cdcf5bae3 100644 (file)
@@ -1,3 +1,8 @@
+2019-02-25  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/89285
+       * g++.dg/cpp1y/constexpr-89285-2.C: New test.
+
 2019-02-25  Dominique d'Humieres  <dominiq@gcc.gnu.org>
 
        PR libfortran/89274
diff --git a/gcc/testsuite/g++.dg/cpp1y/constexpr-89285-2.C b/gcc/testsuite/g++.dg/cpp1y/constexpr-89285-2.C
new file mode 100644 (file)
index 0000000..656bc9c
--- /dev/null
@@ -0,0 +1,20 @@
+// PR c++/89285
+// { dg-do compile { target c++14 } }
+
+struct A {
+  int a {};
+};
+struct B {
+  int b {};
+  constexpr B (A *x) {
+    int *c = &x->a;
+    while (*c)
+      c = reinterpret_cast<int *>((reinterpret_cast<char *>(c) + *c));
+    *c = reinterpret_cast<char *>(this) - reinterpret_cast<char *>(c);
+  }
+};
+struct C : A {
+  B bar {this};
+};
+
+C foo {};