llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

[Clang] Assertion `ItemTypes.back() == toPrimType<T>()' failed with __builtin_isfpclass.

Open RainFly-code opened this issue 3 months ago • 8 comments

Reproducer: Godbolt: https://godbolt.org/z/srjxPeo1b

Compile the testcase with Clang on x86.With the experimental new constant interpreter enabled: -fexperimental-new-constant-interpreter

int main(){
    int a = 1;
    char A[__builtin_isfpclass(1.0f, a)];
}

Backtrace:

clang++: /root/llvm-project/llvm/tools/clang/lib/AST/ByteCode/InterpStack.h:41: T clang::interp::InterpStack::pop() [with T = clang::interp::Integral<32, true>]: Assertion `ItemTypes.back() == toPrimType<T>()' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace and dumped files.
Stack dump:
0.	Program arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/clang++ -g -o /app/output.s -mllvm --x86-asm-syntax=intel -fno-verbose-asm -S --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics -fexperimental-new-constant-interpreter <source>
1.	<source>:3:41: current parser token ';'
2.	<source>:1:11: parsing function body 'main'
3.	<source>:1:11: in compound statement ('{}')
 #0 0x000000000446a258 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x446a258)
 #1 0x0000000004467104 llvm::sys::RunSignalHandlers() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4467104)
 #2 0x000000000446773c llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x446773c)
 #3 0x00000000043a6018 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #4 0x00007f97f2245330 (/lib/x86_64-linux-gnu/libc.so.6+0x45330)
 #5 0x00007f97f229ec0c pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x9ec0c)
 #6 0x00007f97f224527e raise (/lib/x86_64-linux-gnu/libc.so.6+0x4527e)
 #7 0x00007f97f22288ff abort (/lib/x86_64-linux-gnu/libc.so.6+0x288ff)
 #8 0x00007f97f222881b (/lib/x86_64-linux-gnu/libc.so.6+0x2881b)
 #9 0x00007f97f223b517 (/lib/x86_64-linux-gnu/libc.so.6+0x3b517)
#10 0x000000000833f95d clang::interp::popToAPSInt(clang::interp::InterpStack&, clang::interp::PrimType, llvm::APSInt&) InterpBuiltin.cpp:0:0
#11 0x0000000008381d0a clang::interp::InterpretBuiltin(clang::interp::InterpState&, clang::interp::CodePtr, clang::CallExpr const*, unsigned int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x8381d0a)
#12 0x00000000086c2222 clang::interp::Compiler<clang::interp::EvalEmitter>::VisitBuiltinCallExpr(clang::CallExpr const*, unsigned int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x86c2222)
#13 0x00000000086c2bc3 clang::interp::Compiler<clang::interp::EvalEmitter>::VisitCallExpr(clang::CallExpr const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x86c2bc3)
#14 0x00000000086cb310 clang::interp::Compiler<clang::interp::EvalEmitter>::visit(clang::Expr const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x86cb310)
#15 0x00000000086bf0fa clang::interp::Compiler<clang::interp::EvalEmitter>::visitExpr(clang::Expr const*, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x86bf0fa)
#16 0x0000000008216d57 clang::interp::EvalEmitter::interpretExpr(clang::Expr const*, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x8216d57)
#17 0x000000000820ea9a clang::interp::Context::evaluateAsRValue(clang::interp::State&, clang::Expr const*, clang::APValue&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x820ea9a)
#18 0x000000000816f6a2 EvaluateAsRValue((anonymous namespace)::EvalInfo&, clang::Expr const*, clang::APValue&) ExprConstant.cpp:0:0
#19 0x0000000008175a0e clang::Expr::EvaluateAsRValue(clang::Expr::EvalResult&, clang::ASTContext const&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x8175a0e)
#20 0x000000000732e876 clang::Sema::VerifyIntegerConstantExpression(clang::Expr*, llvm::APSInt*, clang::Sema::VerifyICEDiagnoser&, clang::AllowFoldKind) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x732e876)
#21 0x0000000007a3ea4e clang::Sema::BuildArrayType(clang::QualType, clang::ArraySizeModifier, clang::Expr*, unsigned int, clang::SourceRange, clang::DeclarationName) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x7a3ea4e)
#22 0x0000000007a53ea2 GetFullTypeForDeclarator((anonymous namespace)::TypeProcessingState&, clang::QualType, clang::TypeSourceInfo*) SemaType.cpp:0:0
#23 0x0000000007a59135 clang::Sema::GetTypeForDeclarator(clang::Declarator&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x7a59135)
#24 0x00000000071c1f74 clang::Sema::HandleDeclarator(clang::Scope*, clang::Declarator&, llvm::MutableArrayRef<clang::TemplateParameterList*>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x71c1f74)
#25 0x00000000071c3194 clang::Sema::ActOnDeclarator(clang::Scope*, clang::Declarator&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x71c3194)
#26 0x0000000006dc41d3 clang::Parser::ParseDeclarationAfterDeclaratorAndAttributes(clang::Declarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::ForRangeInit*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6dc41d3)
#27 0x0000000006de4f29 clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::ParsedAttributes&, clang::Parser::ParsedTemplateInfo&, clang::SourceLocation*, clang::Parser::ForRangeInit*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6de4f29)
#28 0x0000000006de636f clang::Parser::ParseSimpleDeclaration(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::ParsedAttributes&, bool, clang::Parser::ForRangeInit*, clang::SourceLocation*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6de636f)
#29 0x0000000006de683c clang::Parser::ParseDeclaration(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::ParsedAttributes&, clang::SourceLocation*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6de683c)
#30 0x0000000006e95984 clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*, 24u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*, clang::ParsedAttributes&, clang::ParsedAttributes&, clang::LabelDecl*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6e95984)
#31 0x0000000006e96279 clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*, 24u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*, clang::LabelDecl*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6e96279)
#32 0x0000000006e9e795 clang::Parser::ParseCompoundStatementBody(bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6e9e795)
#33 0x0000000006e9efda clang::Parser::ParseFunctionStatementBody(clang::Decl*, clang::Parser::ParseScope&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6e9efda)
#34 0x0000000006d9bf2d clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&, clang::Parser::ParsedTemplateInfo const&, clang::LateParsedAttrList*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6d9bf2d)
#35 0x0000000006de5996 clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::ParsedAttributes&, clang::Parser::ParsedTemplateInfo&, clang::SourceLocation*, clang::Parser::ForRangeInit*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6de5996)
#36 0x0000000006d9035b clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6d9035b)
#37 0x0000000006d90b4f clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6d90b4f)
#38 0x0000000006d9d308 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6d9d308)
#39 0x0000000006d9e265 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6d9e265)
#40 0x0000000006d9e650 clang::Parser::ParseFirstTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6d9e650)
#41 0x0000000006d7b18c clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6d7b18c)
#42 0x0000000004f62ac8 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4f62ac8)
#43 0x000000000528e078 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x528e078)
#44 0x000000000521b16d clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x521b16d)
#45 0x0000000005363d9d clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x5363d9d)
#46 0x0000000000dabb1c cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xdabb1c)
#47 0x0000000000da273a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>) driver.cpp:0:0
#48 0x0000000000da28bd int llvm::function_ref<int (llvm::SmallVectorImpl<char const*>&)>::callback_fn<clang_main(int, char**, llvm::ToolContext const&)::'lambda'(llvm::SmallVectorImpl<char const*>&)>(long, llvm::SmallVectorImpl<char const*>&) driver.cpp:0:0
#49 0x0000000004fdb789 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
#50 0x00000000043a6454 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x43a6454)
#51 0x0000000004fdc2f5 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
#52 0x0000000004f93fa2 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4f93fa2)
#53 0x0000000004f98907 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+++0x4f98907)
#54 0x0000000004fa2fd5 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4fa2fd5)
#55 0x0000000000da801a clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xda801a)
#56 0x0000000000cc3d8a main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xcc3d8a)
#57 0x00007f97f222a1ca (/lib/x86_64-linux-gnu/libc.so.6+0x2a1ca)
#58 0x00007f97f222a28b __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2a28b)
#59 0x0000000000da20e5 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xda20e5)
clang++: error: clang frontend command failed due to signal (use -v to see invocation)
Compiler returned: 134

The issue reproduces on x86 with Clang 19.1 and later versions through trunk, but does not reproduce with Clang 20.1.0.

  • This may be related to #176549, which has the same assertion:Assertion `ItemTypes.back() == toPrimType()' failed. However, #176549 has already been fixed, and this reproducer still crashes on current trunk.

  • It may also be related to #173814. However, the version ranges differ: #173814 reproduces with Clang 20.1.0, while this reproducer does not.

This testcase was generated by fuzzer.

RainFly-code avatar Aug 14 '26 10:08 RainFly-code

@llvm/issue-subscribers-clang-frontend

Author: RainFly (RainFly-code)

Reproducer: Godbolt: https://godbolt.org/z/srjxPeo1b

Compile the testcase with Clang on x86.With the experimental new constant interpreter enabled: -fexperimental-new-constant-interpreter

int main(){
    int a = 1;
    char A[__builtin_isfpclass(1.0f, a)];
}

Backtrace:

clang++: /root/llvm-project/llvm/tools/clang/lib/AST/ByteCode/InterpStack.h:41: T clang::interp::InterpStack::pop() [with T = clang::interp::Integral&lt;32, true&gt;]: Assertion `ItemTypes.back() == toPrimType&lt;T&gt;()' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace and dumped files.
Stack dump:
0.	Program arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/clang++ -g -o /app/output.s -mllvm --x86-asm-syntax=intel -fno-verbose-asm -S --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics -fexperimental-new-constant-interpreter &lt;source&gt;
1.	&lt;source&gt;:3:41: current parser token ';'
2.	&lt;source&gt;:1:11: parsing function body 'main'
3.	&lt;source&gt;:1:11: in compound statement ('{}')
 #<!-- -->0 0x000000000446a258 llvm::sys::PrintStackTrace(llvm::raw_ostream&amp;, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x446a258)
 #<!-- -->1 0x0000000004467104 llvm::sys::RunSignalHandlers() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4467104)
 #<!-- -->2 0x000000000446773c llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x446773c)
 #<!-- -->3 0x00000000043a6018 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #<!-- -->4 0x00007f97f2245330 (/lib/x86_64-linux-gnu/libc.so.6+0x45330)
 #<!-- -->5 0x00007f97f229ec0c pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x9ec0c)
 #<!-- -->6 0x00007f97f224527e raise (/lib/x86_64-linux-gnu/libc.so.6+0x4527e)
 #<!-- -->7 0x00007f97f22288ff abort (/lib/x86_64-linux-gnu/libc.so.6+0x288ff)
 #<!-- -->8 0x00007f97f222881b (/lib/x86_64-linux-gnu/libc.so.6+0x2881b)
 #<!-- -->9 0x00007f97f223b517 (/lib/x86_64-linux-gnu/libc.so.6+0x3b517)
#<!-- -->10 0x000000000833f95d clang::interp::popToAPSInt(clang::interp::InterpStack&amp;, clang::interp::PrimType, llvm::APSInt&amp;) InterpBuiltin.cpp:0:0
#<!-- -->11 0x0000000008381d0a clang::interp::InterpretBuiltin(clang::interp::InterpState&amp;, clang::interp::CodePtr, clang::CallExpr const*, unsigned int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x8381d0a)
#<!-- -->12 0x00000000086c2222 clang::interp::Compiler&lt;clang::interp::EvalEmitter&gt;::VisitBuiltinCallExpr(clang::CallExpr const*, unsigned int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x86c2222)
#<!-- -->13 0x00000000086c2bc3 clang::interp::Compiler&lt;clang::interp::EvalEmitter&gt;::VisitCallExpr(clang::CallExpr const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x86c2bc3)
#<!-- -->14 0x00000000086cb310 clang::interp::Compiler&lt;clang::interp::EvalEmitter&gt;::visit(clang::Expr const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x86cb310)
#<!-- -->15 0x00000000086bf0fa clang::interp::Compiler&lt;clang::interp::EvalEmitter&gt;::visitExpr(clang::Expr const*, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x86bf0fa)
#<!-- -->16 0x0000000008216d57 clang::interp::EvalEmitter::interpretExpr(clang::Expr const*, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x8216d57)
#<!-- -->17 0x000000000820ea9a clang::interp::Context::evaluateAsRValue(clang::interp::State&amp;, clang::Expr const*, clang::APValue&amp;) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x820ea9a)
#<!-- -->18 0x000000000816f6a2 EvaluateAsRValue((anonymous namespace)::EvalInfo&amp;, clang::Expr const*, clang::APValue&amp;) ExprConstant.cpp:0:0
#<!-- -->19 0x0000000008175a0e clang::Expr::EvaluateAsRValue(clang::Expr::EvalResult&amp;, clang::ASTContext const&amp;, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x8175a0e)
#<!-- -->20 0x000000000732e876 clang::Sema::VerifyIntegerConstantExpression(clang::Expr*, llvm::APSInt*, clang::Sema::VerifyICEDiagnoser&amp;, clang::AllowFoldKind) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x732e876)
#<!-- -->21 0x0000000007a3ea4e clang::Sema::BuildArrayType(clang::QualType, clang::ArraySizeModifier, clang::Expr*, unsigned int, clang::SourceRange, clang::DeclarationName) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x7a3ea4e)
#<!-- -->22 0x0000000007a53ea2 GetFullTypeForDeclarator((anonymous namespace)::TypeProcessingState&amp;, clang::QualType, clang::TypeSourceInfo*) SemaType.cpp:0:0
#<!-- -->23 0x0000000007a59135 clang::Sema::GetTypeForDeclarator(clang::Declarator&amp;) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x7a59135)
#<!-- -->24 0x00000000071c1f74 clang::Sema::HandleDeclarator(clang::Scope*, clang::Declarator&amp;, llvm::MutableArrayRef&lt;clang::TemplateParameterList*&gt;) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x71c1f74)
#<!-- -->25 0x00000000071c3194 clang::Sema::ActOnDeclarator(clang::Scope*, clang::Declarator&amp;) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x71c3194)
#<!-- -->26 0x0000000006dc41d3 clang::Parser::ParseDeclarationAfterDeclaratorAndAttributes(clang::Declarator&amp;, clang::Parser::ParsedTemplateInfo const&amp;, clang::Parser::ForRangeInit*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6dc41d3)
#<!-- -->27 0x0000000006de4f29 clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&amp;, clang::DeclaratorContext, clang::ParsedAttributes&amp;, clang::Parser::ParsedTemplateInfo&amp;, clang::SourceLocation*, clang::Parser::ForRangeInit*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6de4f29)
#<!-- -->28 0x0000000006de636f clang::Parser::ParseSimpleDeclaration(clang::DeclaratorContext, clang::SourceLocation&amp;, clang::ParsedAttributes&amp;, clang::ParsedAttributes&amp;, bool, clang::Parser::ForRangeInit*, clang::SourceLocation*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6de636f)
#<!-- -->29 0x0000000006de683c clang::Parser::ParseDeclaration(clang::DeclaratorContext, clang::SourceLocation&amp;, clang::ParsedAttributes&amp;, clang::ParsedAttributes&amp;, clang::SourceLocation*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6de683c)
#<!-- -->30 0x0000000006e95984 clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector&lt;clang::Stmt*, 24u&gt;&amp;, clang::Parser::ParsedStmtContext, clang::SourceLocation*, clang::ParsedAttributes&amp;, clang::ParsedAttributes&amp;, clang::LabelDecl*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6e95984)
#<!-- -->31 0x0000000006e96279 clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector&lt;clang::Stmt*, 24u&gt;&amp;, clang::Parser::ParsedStmtContext, clang::SourceLocation*, clang::LabelDecl*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6e96279)
#<!-- -->32 0x0000000006e9e795 clang::Parser::ParseCompoundStatementBody(bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6e9e795)
#<!-- -->33 0x0000000006e9efda clang::Parser::ParseFunctionStatementBody(clang::Decl*, clang::Parser::ParseScope&amp;) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6e9efda)
#<!-- -->34 0x0000000006d9bf2d clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&amp;, clang::Parser::ParsedTemplateInfo const&amp;, clang::LateParsedAttrList*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6d9bf2d)
#<!-- -->35 0x0000000006de5996 clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&amp;, clang::DeclaratorContext, clang::ParsedAttributes&amp;, clang::Parser::ParsedTemplateInfo&amp;, clang::SourceLocation*, clang::Parser::ForRangeInit*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6de5996)
#<!-- -->36 0x0000000006d9035b clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&amp;, clang::ParsedAttributes&amp;, clang::ParsingDeclSpec&amp;, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6d9035b)
#<!-- -->37 0x0000000006d90b4f clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&amp;, clang::ParsedAttributes&amp;, clang::ParsingDeclSpec*, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6d90b4f)
#<!-- -->38 0x0000000006d9d308 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&amp;, clang::ParsedAttributes&amp;, clang::ParsingDeclSpec*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6d9d308)
#<!-- -->39 0x0000000006d9e265 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr&lt;clang::DeclGroupRef&gt;&amp;, clang::Sema::ModuleImportState&amp;) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6d9e265)
#<!-- -->40 0x0000000006d9e650 clang::Parser::ParseFirstTopLevelDecl(clang::OpaquePtr&lt;clang::DeclGroupRef&gt;&amp;, clang::Sema::ModuleImportState&amp;) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6d9e650)
#<!-- -->41 0x0000000006d7b18c clang::ParseAST(clang::Sema&amp;, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6d7b18c)
#<!-- -->42 0x0000000004f62ac8 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4f62ac8)
#<!-- -->43 0x000000000528e078 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x528e078)
#<!-- -->44 0x000000000521b16d clang::CompilerInstance::ExecuteAction(clang::FrontendAction&amp;) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x521b16d)
#<!-- -->45 0x0000000005363d9d clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x5363d9d)
#<!-- -->46 0x0000000000dabb1c cc1_main(llvm::ArrayRef&lt;char const*&gt;, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xdabb1c)
#<!-- -->47 0x0000000000da273a ExecuteCC1Tool(llvm::SmallVectorImpl&lt;char const*&gt;&amp;, llvm::ToolContext const&amp;, llvm::IntrusiveRefCntPtr&lt;llvm::vfs::FileSystem&gt;) driver.cpp:0:0
#<!-- -->48 0x0000000000da28bd int llvm::function_ref&lt;int (llvm::SmallVectorImpl&lt;char const*&gt;&amp;)&gt;::callback_fn&lt;clang_main(int, char**, llvm::ToolContext const&amp;)::'lambda'(llvm::SmallVectorImpl&lt;char const*&gt;&amp;)&gt;(long, llvm::SmallVectorImpl&lt;char const*&gt;&amp;) driver.cpp:0:0
#<!-- -->49 0x0000000004fdb789 void llvm::function_ref&lt;void ()&gt;::callback_fn&lt;clang::driver::CC1Command::Execute(llvm::ArrayRef&lt;std::optional&lt;llvm::StringRef&gt;&gt;, std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt;&gt;*, bool*) const::'lambda'()&gt;(long) Job.cpp:0:0
#<!-- -->50 0x00000000043a6454 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref&lt;void ()&gt;) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x43a6454)
#<!-- -->51 0x0000000004fdc2f5 clang::driver::CC1Command::Execute(llvm::ArrayRef&lt;std::optional&lt;llvm::StringRef&gt;&gt;, std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt;&gt;*, bool*) const (.part.0) Job.cpp:0:0
#<!-- -->52 0x0000000004f93fa2 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&amp;, clang::driver::Command const*&amp;, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4f93fa2)
#<!-- -->53 0x0000000004f98907 clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&amp;, llvm::SmallVectorImpl&lt;std::pair&lt;int, clang::driver::Command const*&gt;&gt;&amp;, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4f98907)
#<!-- -->54 0x0000000004fa2fd5 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&amp;, llvm::SmallVectorImpl&lt;std::pair&lt;int, clang::driver::Command const*&gt;&gt;&amp;) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4fa2fd5)
#<!-- -->55 0x0000000000da801a clang_main(int, char**, llvm::ToolContext const&amp;) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xda801a)
#<!-- -->56 0x0000000000cc3d8a main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xcc3d8a)
#<!-- -->57 0x00007f97f222a1ca (/lib/x86_64-linux-gnu/libc.so.6+0x2a1ca)
#<!-- -->58 0x00007f97f222a28b __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2a28b)
#<!-- -->59 0x0000000000da20e5 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xda20e5)
clang++: error: clang frontend command failed due to signal (use -v to see invocation)
Compiler returned: 134

The issue reproduces on x86 with Clang 19.1 and later versions through trunk, but does not reproduce with Clang 20.1.0.

  • This may be related to #176549, which has the same assertion:Assertion `ItemTypes.back() == toPrimType<T>()' failed. However, #176549 has already been fixed, and this reproducer still crashes on current trunk.

  • It may also be related to #173814. However, the version ranges differ: #173814 reproduces with Clang 20.1.0, while this reproducer does not.

This testcase was generated by fuzzer.

This testcase was generated by fuzzer.

FYI: https://github.com/llvm/llvm-project/issues/212719#issuecomment-5115708791

k-arrows avatar Aug 14 '26 10:08 k-arrows

This testcase was generated by fuzzer.

FYI: #212719 (comment)

I checked the existing issues in the experimental/ByteCode directory, and it does not seem to be a duplicate of any of them.

RainFly-code avatar Aug 14 '26 11:08 RainFly-code

What I meant was that if we're going to continue fuzzing, it might be wiser not to file issues for bugs in the bytecode interpreter, given the developers' stance on the matter.

k-arrows avatar Aug 14 '26 11:08 k-arrows

What I meant was that if we're going to continue fuzzing, it might be wiser not to file issues for bugs in the bytecode interpreter, given the developers' stance on the matter.

Got it, I understand.

RainFly-code avatar Aug 14 '26 12:08 RainFly-code

@RainFly-code: Crash reports should be generic blocks, since it's not written in programming language.

EugeneZelenko avatar Aug 14 '26 14:08 EugeneZelenko

@RainFly-code: Crash reports should be generic blocks, since it's not written in programming language.

Sorry about that, and thanks for pointing it out. I'll use generic code blocks for crash reports from now on.

RainFly-code avatar Aug 14 '26 15:08 RainFly-code

It fails just the same with the current interpreter:

clang: /home/tbaeder/code/llvm-project/clang/lib/AST/ExprConstant.cpp:16158: bool EvaluateIntegerOrLValue(const Expr *, APValue &, EvalInfo &): Assertion `E->isPRValue() && E->getType()->isIntegralOrEnumerationType()' failed.

Because nothing ever does the lvalue-to-rvalue conversion on the integer parameter(s), OR just rejects this when the parameter is not an integer literal.

The AST is:

CallExpr 0x7d56b7c53c98 'int'
|-ImplicitCastExpr 0x7d56b7c53c78 'int (*)()' <BuiltinFnToFnPtr>
| `-DeclRefExpr 0x7d56b7c53bc8 '<builtin fn type>' Function 0x7d56b7c53a48 '__builtin_isfpclass' 'int ()'
|-FloatingLiteral 0x7d56b7c53bf0 'float' 1.000000e+00
`-DeclRefExpr 0x7d56b7c53c18 'int' lvalue Var 0x7d56b7c53990 'a' 'int'

tbaederr avatar Aug 15 '26 04:08 tbaederr