Debian Codegraph @

gcc/testsuite/g++.dg/cpp1y/constexpr-104284-2.C

raw
1 // PR c++/104284
2 // { dg-do compile { target c++14 } }
3 // { dg-additional-options "-fchecking=2" }
4
5 struct S {
6 char a;
7 constexpr S() : a{'a'} { }
8 constexpr S(char a_) : a{a_} { }
9 };
10
11 auto x1 = [](auto) { constexpr S s[]{{}}; };
12 auto x2 = [](auto) { constexpr S s[]{{'a'}}; };
13 auto x3 = [](auto) { constexpr S s[]{'a'}; };
14 auto x4 = [](auto) { constexpr S s[]{{{}}}; };
15
16 template<typename>
17 constexpr void g()
18 {
19 constexpr S s1[]{{}};
20 static_assert(s1[0].a == 'a', "");
21 constexpr S s2[]{{'a'}};
22 static_assert(s2[0].a == 'a', "");
23 constexpr S s3[]{'a'};
24 static_assert(s3[0].a == 'a', "");
25 constexpr S s4[]{{{}}};
26 static_assert(s4[0].a == '\0', "");
27 }
28
29 void
30 f ()
31 {
32 g<int>();
33 }