gcc/testsuite/g++.dg/cpp1y/constexpr-tracking-const24.C
raw| 1 | // PR c++/94772 |
| 2 | // { dg-do compile { target c++14 } } |
| 3 | |
| 4 | struct base |
| 5 | { |
| 6 | base() = default; |
| 7 | |
| 8 | constexpr base(int) : base{} { } |
| 9 | }; |
| 10 | |
| 11 | struct foo : base |
| 12 | { |
| 13 | int x{}; |
| 14 | |
| 15 | constexpr foo(int a) : base{a} |
| 16 | { x = -a; } |
| 17 | |
| 18 | constexpr foo(int a, int b) : foo{a} |
| 19 | { x += a + b; } |
| 20 | }; |
| 21 | |
| 22 | int main() |
| 23 | { |
| 24 | constexpr foo bar{1, 2}; |
| 25 | static_assert(bar.x == 2, ""); |
| 26 | } |