<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/69205>69205</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
clang: Assertion `isa<To>(Val) && "cast<Ty>() argument of incompatible type!"' failed.
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
connglli
</td>
</tr>
</table>
<pre>
Compiler explorer: https://godbolt.org/z/rMY3eM83x.
The following program `small.c` triggers a crash in clang-18:
``` sh
% cat small.c
__attribute__((callback(a)))
void f(a);
% clang -O0 small.c
<source>:2:8: error: a parameter list without types is only allowed in a function definition
2 | void f(a);
| ^
clang: /root/llvm-project/llvm/include/llvm/Support/Casting.h:578: decltype(auto) llvm::cast(From*) [with To = clang::FunctionProtoType; From = const clang::FunctionType]: Assertion `isa<To>(Val) && "cast<Ty>() argument of incompatible 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-9.2.0 -fcolor-diagnostics -fno-crash-diagnostics -O0 <source>
1. <source>:2:10: current parser token ';'
#0 0x000000000372f498 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x372f498)
#1 0x000000000372d15c llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x372d15c)
#2 0x0000000003675a78 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#3 0x00007fbf31228420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
#4 0x00007fbf30ceb00b raise (/lib/x86_64-linux-gnu/libc.so.6+0x4300b)
#5 0x00007fbf30cca859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x22859)
#6 0x00007fbf30cca729 (/lib/x86_64-linux-gnu/libc.so.6+0x22729)
#7 0x00007fbf30cdbfd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)
#8 0x000000000621fecd getFunctionOrMethodNumParams(clang::Decl const*) SemaDeclAttr.cpp:0:0
#9 0x000000000625e997 handleCallbackAttr(clang::Sema&, clang::Decl*, clang::ParsedAttr const&) SemaDeclAttr.cpp:0:0
#10 0x0000000006276ae8 ProcessDeclAttribute(clang::Sema&, clang::Scope*, clang::Decl*, clang::ParsedAttr const&, clang::Sema::ProcessDeclAttributeOptions const&) (.isra.0) SemaDeclAttr.cpp:0:0
#11 0x00000000062784a3 clang::Sema::ProcessDeclAttributes(clang::Scope*, clang::Decl*, clang::Declarator const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x62784a3)
#12 0x0000000006212af2 clang::Sema::ActOnFunctionDeclarator(clang::Scope*, clang::Declarator&, clang::DeclContext*, clang::TypeSourceInfo*, clang::LookupResult&, llvm::MutableArrayRef<clang::TemplateParameterList*>, bool&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x6212af2)
#13 0x0000000006217ef3 clang::Sema::HandleDeclarator(clang::Scope*, clang::Declarator&, llvm::MutableArrayRef<clang::TemplateParameterList*>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x6217ef3)
#14 0x0000000006218bd1 clang::Sema::ActOnDeclarator(clang::Scope*, clang::Declarator&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x6218bd1)
#15 0x0000000005eca94f clang::Parser::ParseDeclarationAfterDeclaratorAndAttributes(clang::Declarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::ForRangeInit*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5eca94f)
#16 0x0000000005ed8310 clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::ParsedAttributes&, clang::SourceLocation*, clang::Parser::ForRangeInit*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5ed8310)
#17 0x0000000005ea596b clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5ea596b)
#18 0x0000000005ea609f clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) (.part.0) Parser.cpp:0:0
#19 0x0000000005eada44 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5eada44)
#20 0x0000000005eae26d clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5eae26d)
#21 0x0000000005eae6b0 clang::Parser::ParseFirstTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5eae6b0)
#22 0x0000000005ea12e2 clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5ea12e2)
#23 0x000000000499b538 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x499b538)
#24 0x00000000041fefa9 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x41fefa9)
#25 0x000000000418044e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x418044e)
#26 0x00000000042de12e clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x42de12e)
#27 0x0000000000befa56 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xbefa56)
#28 0x0000000000be731a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#29 0x0000000003fdc649 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const::'lambda'()>(long) Job.cpp:0:0
#30 0x0000000003675f24 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3675f24)
#31 0x0000000003fdcc3f clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (.part.0) Job.cpp:0:0
#32 0x0000000003fa4e05 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3fa4e05)
#33 0x0000000003fa586d clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3fa586d)
#34 0x0000000003fad795 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3fad795)
#35 0x0000000000becefc clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xbecefc)
#36 0x0000000000ae7091 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xae7091)
#37 0x00007fbf30ccc083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#38 0x0000000000be6dfe _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xbe6dfe)
clang: error: clang frontend command failed with exit code 134 (use -v to see invocation)
```
Clang version:
```
clang version 18.0.0 (https://github.com/llvm/llvm-project.git ab737a86993bc7bf92cbb9d51f47f8825a717333)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /opt/compiler-explorer/clang-assertions-trunk/bin
Compiler returned: 0
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzkWl1v27oZ_jXMDWFDor4vcuE68VmLdgma4AC7MiiKkrnSpEZSqbNfP5CSYlGx03T1KTAsyDl1SOrl8z7vpylirVkjKL0GyQeQ3FzhzuykuiZSiIZzdlXK6vl6Lfct41RBemi5VFSBaAV3xrQaRCuANgBtGlmVkpulVA1Am38DtFFf_hHRL3l0WILgBgSr_v-POwprybn8zkQDWyUbhfcQpIHeY86XBKQBNIo1DVUaYkgU1jvIBCQci2YR5nbDiTiQBv0v1LthBCWQYANHeW5wu8XGKFZ2hm63AOUA5QRzXmLyDaAcA1T0v7Bf_iRZBetxJvrg7WjlWzBwcRf4u4BorWWnCAXRLYhWCEQrixdSpaSjDMMWK7ynhirImTbwOzM72RlonluqIdNQCv4MsaWHVlZtDOtOEMOkgBWtmWD2Y78bhBAiCLI1PA0Xuh87D5LbfsjhtkCseaQ0AG04f9ovWiX_Scn4J0AbJgjvKnoceOjaViq7Yo21YaJZ7kC0SjKnX0UJtxpYBJ2Rlkf3WLQC0YpgbQDKN0ruAVo5jpMPVm_4KCGIbuAICkSrzaDrvZJGPlqJ0Qdon-wXSqHNqeVuZXJjoay0psrRBdKAaQyi9aO05kD5n5i73VEKUAoBQg5ZtH587uftJFZNt6fCQFlDJojct9iwklPYqxcChADKYI0Zp9Xg1_efb1cPt1B35Z4ZiGHZNVBRyxY0ch4lzOy6ckksFyO1MwswrTuqAdpALKwLOENAs6NDLFifNQoTCtAatoq2ShKqNa3g4Hto7Z7EWkvCsKEVVJ2AmijWmgHyg8HkG6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