gcc/testsuite/g++.dg/cpp1y/constexpr-99859-1.C
raw| 1 | // PR c++/99859 |
| 2 | // { dg-do compile { target c++14 } } |
| 3 | |
| 4 | constexpr int |
| 5 | foo (int *x) |
| 6 | { |
| 7 | return ++*x; |
| 8 | } |
| 9 | |
| 10 | struct S { constexpr S () : a(0) { foo (&a); foo (&a); } int a; }; |
| 11 | constexpr S s = S (); |
| 12 | static_assert (s.a == 2, ""); |
| 13 | |
| 14 | struct R { int *p; }; |
| 15 | |
| 16 | constexpr int |
| 17 | bar (R x) |
| 18 | { |
| 19 | return ++*x.p; |
| 20 | } |
| 21 | |
| 22 | struct T { int a = 0; constexpr T () { bar (R{&a}); bar (R{&a}); } }; |
| 23 | constexpr T t = T (); |
| 24 | static_assert (t.a == 2, ""); |