tree-optimization/116481 - avoid building function_type[]
[official-gcc.git] / gcc / testsuite / g++.dg / cpp1y / constexpr-tracking-const11.C
blob2b351cd013af6ab688ed75a8480288ec641d16a0
1 // PR c++/91264
2 // { dg-do compile { target c++14 } }
4 struct S {
5     int a = 1;
6     int * ptr = &a;
7 };
9 constexpr bool f() {
10     auto const s = S{}; // { dg-message "originally declared" }
11     *s.ptr = 2; // { dg-error "modifying a const object" }
12     return s.a == 2;
15 static_assert(f(), ""); // { dg-error "non-constant condition" }
16 // { dg-message "in 'constexpr' expansion of" "" { target *-*-* } .-1 }