Debian Codegraph @

clang/test/SemaCXX/constexpr-array-init.cpp

raw
1 // RUN: %clang_cc1 -std=c++20 -verify %s
2
3 /// This test case used to crash in constant evaluation
4 /// because of the two-dimensional array with an array
5 /// filler expression.
6
7 /// expected-no-diagnostics
8 struct Foo {
9 int a;
10 constexpr Foo()
11 : a(get_int()) {
12 }
13
14 constexpr int get_int() const {
15 return 5;
16 }
17 };
18
19 static constexpr Foo bar[2][1] = {
20 {{}},
21 };
22 static_assert(bar[0][0].a == 5);
23 static_assert(bar[1][0].a == 5);
24