xref: /llvm-project/clang/test/SemaCXX/constexpr-single-element-array.cpp (revision d437e68b5b5a1f0291a0eaa72a07712e7aaccd10)
1 // RUN: %clang_cc1 -std=c++20 -verify %s
2 // RUN: %clang_cc1 -std=c++20 -verify -fexperimental-new-constant-interpreter %s
3 
4 
5 // This test makes sure that a single element array doesn't produce
6 // spurious errors during constexpr evaluation.
7 
8 // expected-no-diagnostics
9 struct Sub { int x; };
10 
11 struct S {
SS12   constexpr S() { Arr[0] = Sub{}; }
13   Sub Arr[1];
14 };
15 
test()16 constexpr bool test() {
17   S s;
18   return true;
19 }
20 
21 static_assert(test());
22