Debian Codegraph @

gcc/testsuite/g++.dg/cpp1y/pr77830.C

raw
1 // PR c++/77830
2 // { dg-do compile { target c++14 } }
3
4 template <int N>
5 struct P
6 {
7 char arr[N][1];
8 constexpr void foo (const char *, int);
9 };
10
11 template <int N>
12 constexpr void
13 P<N>::foo (const char *, int i)
14 {
15 for (auto j = 0; j < 2; ++j)
16 arr[i][j] = true; // { dg-error "outside the bounds of array type" }
17 }
18
19 template <typename... T>
20 constexpr auto
21 bar (T... a)
22 {
23 const char *s[]{a...};
24 P<sizeof...(a)> p{};
25 for (auto i = 0; i < sizeof...(a); ++i)
26 p.foo (s[i], i); // { dg-message "in .constexpr. expansion of " }
27 return p;
28 }
29
30 int
31 main ()
32 {
33 constexpr auto a = bar ("", ""); // { dg-message "in .constexpr. expansion of " }
34 }