Debian Codegraph @

gcc/testsuite/g++.dg/cpp1y/constexpr-tracking-const5.C

raw
1 // PR c++/91264
2 // { dg-do compile { target c++14 } }
3
4 struct A {
5 mutable int n;
6 constexpr A() : n(1) { n = 2; }
7 };
8
9 struct B {
10 const A a;
11 constexpr B() {
12 const_cast<A &>(a).n = 3;
13 }
14 };
15
16 constexpr B b{};
17 static_assert((b.a.n, 1), "");