From ea229aa8a1bab0770a1fbd65bb577d2dc4925b69 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Mon, 25 Feb 2019 16:01:01 +0100 Subject: [PATCH] re PR c++/89285 (ICE after casting the this pointer in the constructor in C++17 mode) PR c++/89285 * g++.dg/cpp1y/constexpr-89285-2.C: New test. From-SVN: r269188 --- gcc/testsuite/ChangeLog | 5 +++++ .../g++.dg/cpp1y/constexpr-89285-2.C | 20 +++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 gcc/testsuite/g++.dg/cpp1y/constexpr-89285-2.C diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index bbe27aa83a6..70abccc4d1a 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-02-25 Jakub Jelinek + + PR c++/89285 + * g++.dg/cpp1y/constexpr-89285-2.C: New test. + 2019-02-25 Dominique d'Humieres 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 index 00000000000..656bc9cb7f1 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/constexpr-89285-2.C @@ -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((reinterpret_cast(c) + *c)); + *c = reinterpret_cast(this) - reinterpret_cast(c); + } +}; +struct C : A { + B bar {this}; +}; + +C foo {};