<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/92284>92284</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Assert-fail on C++20 paren-agg-init of array type
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
AMP999
</td>
</tr>
</table>
<pre>
https://godbolt.org/z/bns6MrY9E
```
using T = int[1];
T a(42);
```
Compile with `-std=c++20`. Clang assert-fails with the message "Expression result is not a constant array type":
```
clang++: /root/llvm-project/clang/lib/AST/ExprConstant.cpp:11423: bool {anonymous}::ArrayExprEvaluator::VisitCXXParenListInitExpr(const clang::CXXParenListInitExpr*): Assertion `dyn_cast<ConstantArrayType>(E->getType()) && "Expression result is not a constant array type"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0. Program arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/clang++ -gdwarf-4 -g -o /app/output.s -mllvm --x86-asm-syntax=intel -S --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics -std=c++20 <source>
1. <source>:2:8: current parser token ';'
[...]
#8 0x000070eef7839e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#9 0x00000000075eeb0d clang::StmtVisitorBase<llvm::make_const_ptr, (anonymous namespace)::ArrayExprEvaluator, bool>::Visit(clang::Stmt const*) ExprConstant.cpp:0:0
#10 0x00000000075eecad EvaluateArray(clang::Expr const*, (anonymous namespace)::LValue const&, clang::APValue&, (anonymous namespace)::EvalInfo&) ExprConstant.cpp:0:0
#11 0x00000000075ba5e1 EvaluateInPlace(clang::APValue&, (anonymous namespace)::EvalInfo&, (anonymous namespace)::LValue const&, clang::Expr const*, bool) ExprConstant.cpp:0:0
#12 0x00000000075f7393 clang::Expr::EvaluateAsInitializer(clang::APValue&, clang::ASTContext const&, clang::VarDecl const*, llvm::SmallVectorImpl<std::pair<clang::SourceLocation, clang::PartialDiagnostic>>&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x75f7393)
#13 0x00000000074d1382 clang::VarDecl::evaluateValueImpl(llvm::SmallVectorImpl<std::pair<clang::SourceLocation, clang::PartialDiagnostic>>&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x74d1382)
#14 0x00000000074d16d1 clang::VarDecl::checkForConstantInitialization(llvm::SmallVectorImpl<std::pair<clang::SourceLocation, clang::PartialDiagnostic>>&) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x74d16d1)
#15 0x000000000663d505 clang::Sema::CheckCompleteVariableDeclaration(clang::VarDecl*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x663d505)
#16 0x0000000006643dca clang::Sema::AddInitializerToDecl(clang::Decl*, clang::Expr*, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6643dca)
[...]
```
The same crash happens with these variations, all of which are accepted without complaint by GCC:
```
using Ta = int[2]; Ta a(42);
using Tb = int[2]; Tb b(42,43);
using Tc = int[]; Tc c(42);
using Td = int[]; Td d(42,43);
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzcV11v8yoS_jXkZuTIhtixL3LhfK1eqUeq1Ko6e1VhTBy2GCzAb9Pz61dg57PpOe_udvdiq7aSYRie52FmYKi1olGcL1C6ROl6Qnu312ZR_vZYFMWk0vXHYu9cZxEpEd4ivG10XWnppto0CG__QHhbKZv9Zv5ebFC8RnE5_s_i8Td89laoBp4BkTUI5VC6TFC6RmQ5TD8DRTifYYSL09iNh5VuOyE5vAu3B5TFkXU1ImuG8BLhJfaGU1hJqhqg1nLjoh0V0g72bs-h5dbShgPCeHPoDLdWaAWG2146EBaUdkCBaWUdVQ6oMfQD3EfHEcae_T1QzO83IECkBIS3RmuH8FbKn23UGf0PzvznaLeV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