Debian Codegraph @

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

raw
1 // PR c++/104284
2 // { dg-do compile { target c++14 } }
3 // { dg-additional-options "-fchecking=2" }
4 // Like constexpr-104284.C, but the function template is not
5 // constexpr. In that case, we were still calling build_vec_init
6 // in a template, just not crashing.
7
8 struct S {
9 char c{};
10 };
11
12 template<class>
13 void g ()
14 {
15 constexpr S s1[]{{}};
16 static_assert(s1[0].c == '\0', "");
17 constexpr S s2[]{{'a'}};
18 static_assert(s2[0].c == 'a', "");
19 #if __cpp_designated_initializers >= 201707L
20 constexpr S s3[]{{.c = 'a'}};
21 static_assert(s3[0].c == 'a', "");
22 #endif
23 constexpr S s4[]{'a'};
24 static_assert(s4[0].c == 'a', "");
25 constexpr S s5[]{{{}}};
26 static_assert(s5[0].c == '\0', "");
27 }
28
29 void
30 f ()
31 {
32 g<int>();
33 }