xref: /llvm-project/clang/test/SemaCXX/constexpr-array-init.cpp (revision d1942855c4317c61f9fae173afa2cbe1076c3c4c)
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;
FooFoo10   constexpr Foo()
11       : a(get_int()) {
12   }
13 
get_intFoo14   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 
25