Hi!

This testcase ICEs on the 8.x branch and ICEd as well with my earlier
approach to get the testcase rejected on the trunk again when foo is
constexpr, but actually with the latest approach that was committed
(where constexpr evaluation is done on pre-cp_fold_function trees and
cp_fold can optimize away those reinterpret_casts) it doesn't ICE.

So, I've tested this on the trunk with check-c++-all, verified that 8.x ICEs
on it and committed to trunk as obvious.

2019-02-25  Jakub Jelinek  <ja...@redhat.com>

        PR c++/89285
        * g++.dg/cpp1y/constexpr-89285-2.C: New test.

--- gcc/testsuite/g++.dg/cpp1y/constexpr-89285-2.C.jj   2019-02-25 
15:47:55.189265284 +0100
+++ gcc/testsuite/g++.dg/cpp1y/constexpr-89285-2.C      2019-02-25 
15:47:34.937592247 +0100
@@ -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 {};

        Jakub

Reply via email to