<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/104767>104767</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
clang crash when evaluating invalid initalized
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang,
crash-on-invalid
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
kadircet
</td>
</tr>
</table>
<pre>
```cpp
$ cat preprocessed.cc
template <a> long b();
template <typename f = int> struct g {
using h = decltype(b<f>());
h m_fn1();
};
auto o = g();
long a(o.m_fn1());
```
```
$ ~/repos/llvm/build/bin/clang -Wno-everything -std=c++20 -xc++ preprocessed.cc
preprocessed.cc:1:11: error: unknown type name 'a'
1 | template <a> long b();
| ^
preprocessed.cc:3:22: error: no matching function for call to 'b'
3 | using h = decltype(b<f>());
| ^~~~
preprocessed.cc:6:10: note: in instantiation of template class 'g<>' requested here
6 | auto o = g();
| ^
preprocessed.cc:1:19: note: candidate template ignored: invalid explicitly-specified argument for 1st template parameter
1 | template <a> long b();
| ^
clang-20: /usr/local/google/home/kadircet/repos/llvm/clang/include/clang/AST/Type.h:957: const ExtQualsTypeCommonBase *clang::QualType::getCommonPtr() const: Assertion `!isNull() && "Cannot retrieve a NULL type pointer"' 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: /usr/local/google/home/kadircet/repos/llvm/build/bin/clang-20 -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -dumpdir a- -disable-free -clear-ast-before-backend -main-file-name preprocessed.cc -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/usr/local/google/home/kadircet/repos/tmp/clangd_crashes/68c6c10f-0000-2aaf-8985-3c286d3cf65a/0 -fcoverage-compilation-dir=/usr/local/google/home/kadircet/repos/tmp/clangd_crashes/68c6c10f-0000-2aaf-8985-3c286d3cf65a/0 -resource-dir /usr/local/google/home/kadircet/repos/llvm/build/lib/clang/20 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/14/../../../../include/x86_64-linux-gnu/c++/14 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14/backward -internal-isystem /usr/local/google/home/kadircet/repos/llvm/build/lib/clang/20/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/14/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-everything -std=c++20 -fdeprecated-macro -ferror-limit 19 -fgnuc-version=4.2.1 -fno-implicit-modules -fskip-odr-check-in-gmf -fcxx-exceptions -fexceptions -fcolor-diagnostics -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/preprocessed-1b3d70.o -x c++ preprocessed.cc
1. preprocessed.cc:7:18: current parser token ';'
#0 0x00005624ec1b76e8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /usr/local/google/home/kadircet/repos/llvm/llvm/lib/Support/Unix/Signals.inc:723:13
#1 0x00005624ec1b52be llvm::sys::RunSignalHandlers() /usr/local/google/home/kadircet/repos/llvm/llvm/lib/Support/Signals.cpp:106:18
#2 0x00005624ec1b7d98 SignalHandler(int) /usr/local/google/home/kadircet/repos/llvm/llvm/lib/Support/Unix/Signals.inc:413:1
#3 0x00007f29f32591a0 (/lib/x86_64-linux-gnu/libc.so.6+0x3d1a0)
#4 0x00007f29f32a70ec __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
#5 0x00007f29f3259102 gsignal ./signal/../sysdeps/posix/raise.c:27:6
#6 0x00007f29f32424f2 abort ./stdlib/abort.c:81:7
#7 0x00007f29f3242415 _nl_load_domain ./intl/loadmsgcat.c:1177:9
#8 0x00007f29f3251d32 (/lib/x86_64-linux-gnu/libc.so.6+0x35d32)
#9 0x00005624ef975993 doit /usr/local/google/home/kadircet/repos/llvm/llvm/include/llvm/Support/Casting.h:109:5
#10 0x00005624ef975993 doit /usr/local/google/home/kadircet/repos/llvm/llvm/include/llvm/Support/Casting.h:137:12
#11 0x00005624ef975993 doit /usr/local/google/home/kadircet/repos/llvm/llvm/include/llvm/Support/Casting.h:127:12
#12 0x00005624ef975993 isPossible /usr/local/google/home/kadircet/repos/llvm/llvm/include/llvm/Support/Casting.h:255:12
#13 0x00005624ef975993 isPossible /usr/local/google/home/kadircet/repos/llvm/llvm/include/llvm/Support/Casting.h:509:12
#14 0x00005624ef975993 isa<clang::ArrayType, clang::QualType> /usr/local/google/home/kadircet/repos/llvm/llvm/include/llvm/Support/Casting.h:549:10
#15 0x00005624ef975993 isArrayType /usr/local/google/home/kadircet/repos/llvm/clang/include/clang/AST/Type.h:8076:10
#16 0x00005624ef975993 EvaluateInPlace(clang::APValue&, (anonymous namespace)::EvalInfo&, (anonymous namespace)::LValue const&, clang::Expr const*, bool) /usr/local/google/home/kadircet/repos/llvm/clang/lib/AST/ExprConstant.cpp:0:0
#17 0x00005624ef976097 clang::Expr::EvaluateAsInitializer(clang::APValue&, clang::ASTContext const&, clang::VarDecl const*, llvm::SmallVectorImpl<std::pair<clang::SourceLocation, clang::PartialDiagnostic>>&, bool) const /usr/local/google/home/kadircet/repos/llvm/clang/lib/AST/ExprConstant.cpp:16312:12
#18 0x00005624ef8d3fbf clang::VarDecl::evaluateValueImpl(llvm::SmallVectorImpl<std::pair<clang::SourceLocation, clang::PartialDiagnostic>>&, bool) const /usr/local/google/home/kadircet/repos/llvm/clang/lib/AST/Decl.cpp:2572:32
#19 0x00005624ef8d4117 clang::VarDecl::checkForConstantInitialization(llvm::SmallVectorImpl<std::pair<clang::SourceLocation, clang::PartialDiagnostic>>&) const /usr/local/google/home/kadircet/repos/llvm/clang/lib/AST/Decl.cpp:2640:35
#20 0x00005624eeb10f68 clang::Sema::CheckCompleteVariableDeclaration(clang::VarDecl*) /usr/local/google/home/kadircet/repos/llvm/clang/lib/Sema/SemaDecl.cpp:0:27
#21 0x00005624eeb0fc1f clang::Sema::AddInitializerToDecl(clang::Decl*, clang::Expr*, bool) /usr/local/google/home/kadircet/repos/llvm/clang/lib/Sema/SemaDecl.cpp:0:3
#22 0x00005624ee8344b0 InitializerScopeRAII /usr/local/google/home/kadircet/repos/llvm/clang/lib/Parse/ParseDecl.cpp:2670:11
#23 0x00005624ee8344b0 clang::Parser::ParseDeclarationAfterDeclaratorAndAttributes(clang::Declarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::ForRangeInit*) /usr/local/google/home/kadircet/repos/llvm/clang/lib/Parse/ParseDecl.cpp:2842:26
#24 0x00005624ee831ac0 clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::ParsedAttributes&, clang::Parser::ParsedTemplateInfo&, clang::SourceLocation*, clang::Parser::ForRangeInit*) /usr/local/google/home/kadircet/repos/llvm/clang/lib/Parse/ParseDecl.cpp:2523:7
#25 0x00005624ee7ba579 clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) /usr/local/google/home/kadircet/repos/llvm/clang/lib/Parse/Parser.cpp:0:10
#26 0x00005624ee7b9d92 clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) /usr/local/google/home/kadircet/repos/llvm/clang/lib/Parse/Parser.cpp:1266:12
#27 0x00005624ee7b8b79 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) /usr/local/google/home/kadircet/repos/llvm/clang/lib/Parse/Parser.cpp:0:14
#28 0x00005624ee7b6bba clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) /usr/local/google/home/kadircet/repos/llvm/clang/lib/Parse/Parser.cpp:758:10
#29 0x00005624ee7b210e clang::ParseAST(clang::Sema&, bool, bool) /usr/local/google/home/kadircet/repos/llvm/clang/lib/Parse/ParseAST.cpp:170:5
#30 0x00005624ece66a3f clang::FrontendAction::Execute() /usr/local/google/home/kadircet/repos/llvm/clang/lib/Frontend/FrontendAction.cpp:1082:10
#31 0x00005624ecdd1a9d getPtr /usr/local/google/home/kadircet/repos/llvm/llvm/include/llvm/Support/Error.h:279:42
#32 0x00005624ecdd1a9d operator bool /usr/local/google/home/kadircet/repos/llvm/llvm/include/llvm/Support/Error.h:242:16
#33 0x00005624ecdd1a9d clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) /usr/local/google/home/kadircet/repos/llvm/clang/lib/Frontend/CompilerInstance.cpp:1061:23
#34 0x00005624ecf4ebfe clang::ExecuteCompilerInvocation(clang::CompilerInstance*) /usr/local/google/home/kadircet/repos/llvm/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:280:25
#35 0x00005624e9a4ae2b cc1_main(llvm::ArrayRef<char const*>, char const*, void*) /usr/local/google/home/kadircet/repos/llvm/clang/tools/driver/cc1_main.cpp:285:15
#36 0x00005624e9a4750d ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) /usr/local/google/home/kadircet/repos/llvm/clang/tools/driver/driver.cpp:215:12
#37 0x00005624e9a462b8 clang_main(int, char**, llvm::ToolContext const&) /usr/local/google/home/kadircet/repos/llvm/clang/tools/driver/driver.cpp:256:12
#38 0x00005624e9a57c67 main /usr/local/google/home/kadircet/repos/llvm/build/tools/clang/tools/driver/clang-driver.cpp:17:10
#39 0x00007f29f3243b8a __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:74:3
#40 0x00007f29f3243c45 call_init ./csu/../csu/libc-start.c:128:20
#41 0x00007f29f3243c45 __libc_start_main ./csu/../csu/libc-start.c:347:5
#42 0x00005624e9a44e61 _start (/usr/local/google/home/kadircet/repos/llvm/build/bin/clang-20+0x56c0e61)
clang: error: unable to execute command: Aborted
clang: error: clang frontend command failed due to signal (use -v to see invocation)
clang version 20.0.0git (git@github.com:kadircet/llvm-project.git 48b7a2c9ebbb5d8ea6be53ef034d2e67558ef97c)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/google/home/kadircet/repos/llvm/build/bin
Build config: +assertions
clang: note: diagnostic msg:
********************
PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang: note: diagnostic msg: /tmp/preprocessed-ca391b.cpp
clang: note: diagnostic msg: /tmp/preprocessed-ca391b.sh
clang: note: diagnostic msg:
********************
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzcW81y27iyfhp6g4KKBH-18EKRrBlX5Ux8Y8_MUgWCTQonJMADgB77LubZbwGkJJKSk0zi-KZOKjZJEGx8_XWj0fgx1ZpXAuDai9958eaKdmYv1fUnWnDFwFzlsni-9hK__8_a1vM3nr_ySIQYNahV0CrJQGsoFoz1Lw00bU0NIC9cUy-8QbUUFco9knlk6YXvzmuZ5xYEbQCVyAs3iAtjP9NGdcygCnnp8A1CneaiQntXrQBW2y89kuVeuC698GZoY9QMQnvU7EoRzJr30s3xnnZGIulkVrNqDjr1SCYXYyljQQdyhseLhSRCf3tkq6CV2iPbun5sPLLNO14X9sqFR7aspqJC-E8hMTyCejZ7qyrWpvDCDfPIO4-8Iz7CT8P9ZfLnheEqsD_2FwKlpLI3nfgk5F8CWfaQI94jKfVIOnAWIC9do6-zI3L_bP3TPy--eQlN6IUrQiZohEQNNcypW3aCGS4FKqVCjNY1MtKCy0_gEELh0N43eMMBrBff_P333y-hTCxnfg_OgL1ygbjQhgrDqQMoyxNBrKZaW5iVF65dwylS8J8OtIEC7UHBqfnENf8Zl5t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