gcc/testsuite/g++.dg/cpp1y/constexpr-tracking-const11.C
raw| 1 | // PR c++/91264 |
| 2 | // { dg-do compile { target c++14 } } |
| 3 | |
| 4 | struct S { |
| 5 | int a = 1; |
| 6 | int * ptr = &a; |
| 7 | }; |
| 8 | |
| 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; |
| 13 | } |
| 14 | |
| 15 | static_assert(f(), ""); // { dg-error "non-constant condition" } |
| 16 | // { dg-message "in 'constexpr' expansion of" "" { target *-*-* } .-1 } |