Debian Codegraph @

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

raw
1 // PR c++/94772
2 // { dg-do compile { target c++14 } }
3
4 struct foo
5 {
6 int x{};
7
8 constexpr foo() noexcept = default;
9
10 constexpr foo(int a) : foo{}
11 { x = -a; }
12
13 constexpr foo(int a, int b) : foo{a}
14 { x += a + b; }
15 };
16
17 int main()
18 {
19 constexpr foo bar{1, 2};
20 static_assert(bar.x == 2, "");
21 }