<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/63324>63324</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Crash at -O0 on x86_64-linux_gnu: Assertion `isa<T>(CanonicalType)' failed.
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
shao-hua-li
</td>
</tr>
</table>
<pre>
Compiler explorer: https://godbolt.org/z/jWocx1h8E
Input program:
```C
int printf(const char *, ...);
char a, b, c, f;
int d = -1625723284, h = -1306316094;
signed char *e;
long g;
signed char **i = &e;
char j[] = {077};
long(k)() { return 0; }
int l(char *n) {
for (;;)
if (*n <= '9')
;
else
return 0;
}
static int o() {
int m;
c = a - 9;
for (; c == 0;)
for (; b;)
if (k())
return 0;
for (; *e + d + (h - -1306316094) - -1625723339 <= 1;) {
m = 0;
for (; d + (h - -1306316094) - -1625723285 + m <= 1; m++)
for (; g <= 1; g++)
l(j);
return 0;
}
return 7;
}
int main() {
f = 202;
*i = &f;
o();
printf("%d\n", (int)g);
}
```
```console
% clang-tk -O0 -fsanitize=undefined a.c
clang-17: /zdata/shaoli/compilers/ccbuilder-repos/llvm-project/clang/include/clang/AST/Type.h:7520: const T* clang::Type::castAs() const [with T = clang::FunctionProtoType]: Assertion `isa<T>(CanonicalType)' 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: /zdata/shaoli/compilers/ccbuilder-compilers/clang-assertion/bin/clang-17 -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -mrelax-all -dumpdir a- -disable-free -clear-ast-before-backend -main-file-name a.c -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 -fcoverage-compilation-dir=/zdata/shaoli/realsmith/debug -resource-dir /zdata/shaoli/compilers/ccbuilder-compilers/clang-assertion/lib/clang/17 -internal-isystem /zdata/shaoli/compilers/ccbuilder-compilers/clang-assertion/lib/clang/17/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/11/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -O0 -fdebug-compilation-dir=/zdata/shaoli/realsmith/debug -ferror-limit 19 -fsanitize=alignment,array-bounds,bool,builtin,enum,float-cast-overflow,function,integer-divide-by-zero,nonnull-attribute,null,pointer-overflow,return,returns-nonnull-attribute,shift-base,shift-exponent,signed-integer-overflow,unreachable,vla-bound,vptr -fsanitize-recover=alignment,array-bounds,bool,builtin,enum,float-cast-overflow,function,integer-divide-by-zero,nonnull-attribute,null,pointer-overflow,returns-nonnull-attribute,shift-base,shift-exponent,signed-integer-overflow,vla-bound,vptr -fno-sanitize-memory-param-retval -fno-sanitize-address-use-odr-indicator -fgnuc-version=4.2.1 -fcolor-diagnostics -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/a-28d726.o -x c a.c
1. a.c:9:1: current parser token 'int'
2. a.c:8:6: LLVM IR generation of declaration 'k'
3. a.c:8:6: Generating code for declaration 'k'
#0 0x0000558777c0d27f llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/zdata/shaoli/compilers/ccbuilder-compilers/clang-assertion/bin/clang-17+0x3b4627f)
#1 0x0000558777c0a9d4 SignalHandler(int) Signals.cpp:0:0
#2 0x00007f0ccd482420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
#3 0x00007f0ccced300b raise (/lib/x86_64-linux-gnu/libc.so.6+0x4300b)
#4 0x00007f0ccceb2859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x22859)
#5 0x00007f0ccceb2729 (/lib/x86_64-linux-gnu/libc.so.6+0x22729)
#6 0x00007f0cccec3fd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)
#7 0x000055877aee1023 (/zdata/shaoli/compilers/ccbuilder-compilers/clang-assertion/bin/clang-17+0x6e1a023)
#8 0x000055877af1e5e1 clang::ASTContext::getFunctionTypeWithExceptionSpec(clang::QualType, clang::FunctionProtoType::ExceptionSpecInfo const&) const (/zdata/shaoli/compilers/ccbuilder-compilers/clang-assertion/bin/clang-17+0x6e575e1)
#9 0x000055877af1e530 clang::ASTContext::getFunctionTypeWithExceptionSpec(clang::QualType, clang::FunctionProtoType::ExceptionSpecInfo const&) const (/zdata/shaoli/compilers/ccbuilder-compilers/clang-assertion/bin/clang-17+0x6e57530)
#10 0x0000558777fa1961 clang::CodeGen::CodeGenFunction::getUBSanFunctionTypeHash(clang::QualType) const (/zdata/shaoli/compilers/ccbuilder-compilers/clang-assertion/bin/clang-17+0x3eda961)
#11 0x0000558777fb28dc clang::CodeGen::CodeGenFunction::StartFunction(clang::GlobalDecl, clang::QualType, llvm::Function*, clang::CodeGen::CGFunctionInfo const&, clang::CodeGen::FunctionArgList const&, clang::SourceLocation, clang::SourceLocation) (/zdata/shaoli/compilers/ccbuilder-compilers/clang-assertion/bin/clang-17+0x3eeb8dc)
#12 0x0000558777fb64c7 clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&) (/zdata/shaoli/compilers/ccbuilder-compilers/clang-assertion/bin/clang-17+0x3eef4c7)
#13 0x000055877801a919 clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/zdata/shaoli/compilers/ccbuilder-compilers/clang-assertion/bin/clang-17+0x3f53919)
#14 0x00005587780158c5 clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/zdata/shaoli/compilers/ccbuilder-compilers/clang-assertion/bin/clang-17+0x3f4e8c5)
#15 0x0000558778016498 clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl) (/zdata/shaoli/compilers/ccbuilder-compilers/clang-assertion/bin/clang-17+0x3f4f498)
#16 0x000055877801f2d3 clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) (.part.0) CodeGenModule.cpp:0:0
#17 0x0000558778e9f8a6 (anonymous namespace)::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef) ModuleBuilder.cpp:0:0
#18 0x0000558778e8fd00 clang::BackendConsumer::HandleTopLevelDecl(clang::DeclGroupRef) (/zdata/shaoli/compilers/ccbuilder-compilers/clang-assertion/bin/clang-17+0x4dc8d00)
#19 0x000055877a019fa4 clang::ParseAST(clang::Sema&, bool, bool) (/zdata/shaoli/compilers/ccbuilder-compilers/clang-assertion/bin/clang-17+0x5f52fa4)
#20 0x0000558778e9c578 clang::CodeGenAction::ExecuteAction() (/zdata/shaoli/compilers/ccbuilder-compilers/clang-assertion/bin/clang-17+0x4dd5578)
#21 0x00005587786ecd79 clang::FrontendAction::Execute() (/zdata/shaoli/compilers/ccbuilder-compilers/clang-assertion/bin/clang-17+0x4625d79)
#22 0x0000558778671c86 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/zdata/shaoli/compilers/ccbuilder-compilers/clang-assertion/bin/clang-17+0x45aac86)
#23 0x00005587787cf326 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/zdata/shaoli/compilers/ccbuilder-compilers/clang-assertion/bin/clang-17+0x4708326)
#24 0x00005587751280f4 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/zdata/shaoli/compilers/ccbuilder-compilers/clang-assertion/bin/clang-17+0x10610f4)
#25 0x0000558775123e1a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#26 0x00005587751253ec clang_main(int, char**, llvm::ToolContext const&) (/zdata/shaoli/compilers/ccbuilder-compilers/clang-assertion/bin/clang-17+0x105e3ec)
#27 0x000055877503a165 main (/zdata/shaoli/compilers/ccbuilder-compilers/clang-assertion/bin/clang-17+0xf73165)
#28 0x00007f0ccceb4083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#29 0x000055877511ebfe _start (/zdata/shaoli/compilers/ccbuilder-compilers/clang-assertion/bin/clang-17+0x1057bfe)
clang-tk: error: unable to execute command: Aborted
clang-tk: error: clang frontend command failed due to signal (use -v to see invocation)
clang version 17.0.0 (https://github.com/llvm/llvm-project.git 53d405762219d798286b99c297098a14643440fe)
%
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzkWl1v27jS_jXMDUFDor4vcuHYdbdAF2_fTU730qDIkcxGIgWSSpP99QeUZFtyk25bbIJzcBZdRxoOh_M8HA6Hkpi1slYA1yi5Qcn2ivXuoM21PTBNDj0jjbwqtXi63ui2kw0YDI9dow0YFK3xwbnOomiN6A7RXa1FqRu30qZGdPcXorsvf2r-GB7ydyjYomA9_n5QXe9wZ3RtWOs7j21pMP7bjPdSeR2pXIVozrWyDvMDMxjRNaIbvFqtEC1QdDNqD03MN5T-h_uf6tTqbQmMoi0mYUqTjEY0j73KYRJGQRqFaVDEpy4DKeI0JJwaGq1qXL-kh-haDjYRTWHp3ZeR4LE1uwmyDGXbhVlE83sPiuaIFl4HG3C9UThA0Q322ic0jSdlGlNN2mMrxpX24tybjm68vVEuq0FK1wqjaDP6mBWIZmeV4b-TS_4GGgvzxplD07QdvbKOOcmxd06fERz7enE7s8wHGhgmuJhJz56PCl4nWIDAC6Xysg1PKO9HDy7annF_Yc7PM0b0xscK9bf5AZNFdNBiEIwxFEXFkclwdGSOGOMWn_x_zvkfG4TmyaDXzofCLaI3w78FvpnxeqFeX6r78PkyXz8vkHOa3VNr9u3MD3PLpPp21quBARrQucnZCqlm8iloZpLT6keUIpoIlGzUcLnxKKVyiBb1vMvJo1Mumaedk9AnE91MYY1ognnDVE3cPSb_F2BSWaakk38Bira9ElBJv8DZik9reVAOM5_-fJYTzD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