[clang] Assertion `Diagnosed && "failed to diagnose bad conversion"' failed.
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
Reproducer:
https://godbolt.org/z/TaYn6r55f
```c
int main (void)
{
return __builtin_fpclassify ((void *)0, 1, 4, 3, 2, 1);
}
```
Backtrace:
```
:3:32: error: incompatible pointer to integer conversion passing 'void *' to parameter of type 'int' [-Wint-conversion]
3 | return __builtin_fpclassify ((void *)0, 1, 4, 3, 2, 1);
| ^~~~~~~~~
clang: /root/llvm-project/llvm/tools/clang/lib/Sema/SemaExprCXX.cpp:4722: clang::ExprResult clang::Sema::PerformImplicitConversion(clang::Expr*, clang::QualType, const clang::ImplicitConversionSequence&, clang::AssignmentAction, clang::CheckedConversionKind): Assertion `Diagnosed && "failed to diagnose bad conversion"' 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
1. :3:56: current parser token ')'
2. :2:1: parsing function body 'main'
3. :2:1: in compound statement ('{}')
#0 0x000000000442edd8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x442edd8)
#1 0x000000000442bc84 llvm::sys::RunSignalHandlers() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x442bc84)
#2 0x000000000442c2bc llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x442c2bc)
#3 0x000000000436b338 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#4 0x00007d09b6e45330 (/lib/x86_64-linux-gnu/libc.so.6+0x45330)
#5 0x00007d09b6e9ec0c pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x9ec0c)
#6 0x00007d09b6e4527e raise (/lib/x86_64-linux-gnu/libc.so.6+0x4527e)
#7 0x00007d09b6e288ff abort (/lib/x86_64-linux-gnu/libc.so.6+0x288ff)
#8 0x00007d09b6e2881b (/lib/x86_64-linux-gnu/libc.so.6+0x2881b)
#9 0x00007d09b6e3b517 (/lib/x86_64-linux-gnu/libc.so.6+0x3b517)
#10 0x00000000073bd676 clang::Sema::PerformImplicitConversion(clang::Expr*, clang::QualType, clang::ImplicitConversionSequence const&, clang::AssignmentAction, clang::CheckedConversionKind) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x73bd676)
#11 0x00000000076ad8a8 clang::Sema::PerformImplicitConversion(clang::Expr*, clang::QualType, clang::AssignmentAction, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x76ad8a8)
#12 0x0000000006fc427e clang::Sema::BuiltinFPClassification(clang::CallExpr*, unsigned int, unsigned int) (.part.0) SemaChecking.cpp:0:0
#13 0x0000000006ff26f9 clang::Sema::CheckBuiltinFunctionCall(clang::FunctionDecl*, unsigned int, clang::CallExpr*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x6ff26f9)
#14 0x000000000730b62b clang::Sema::BuildResolvedCallExpr(clang::Expr*, clang::NamedDecl*, clang::SourceLocation, llvm::ArrayRef, clang::SourceLocation, clang::Expr*, bool, clang::CallExpr::ADLCallKind) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x730b62b)
#15 0x0000000007305f9c clang::Sema::BuildCallExpr(clang::Scope*, clang::Expr*, clang::SourceLocation, llvm::MutableArrayRef, clang::SourceLocation, clang::Expr*, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x7305f9c)
#16 0x000000000730c4ff clang::Sema::ActOnCallExpr(clang::Scope*, clang::Expr*, clang::SourceLocation, llvm::MutableArrayRef, clang::SourceLocation, clang::Expr*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x730c4ff)
#17 0x0000000006dce053 clang::Parser::ParsePostfixExpressionSuffix(clang::ActionResult) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x6dce053)
#18 0x0000000006dc6a2a clang::Parser::ParseCastExpression(clang::CastParseKind, bool, bool&, clang::TypoCorrectionTypeBehavior, bool, bool*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x6dc6a2a)
#19 0x0000000006dc8cd7 clang::Parser::ParseCastExpression(clang::CastParseKind, bool, clang::TypoCorrectionTypeBehavior, bool, bool*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x6dc8cd7)
#20 0x0000000006dc8d69 clang::Parser::ParseAssignmentExpression(clang::TypoCorrectionTypeBehavior) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x6dc8d69)
#21 0x0000000006dcd659 clang::Parser::ParseExpression(clang::TypoCorrectionTypeBehavior) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x6dcd659)
#22 0x0000000006e4bcb2 clang::Parser::ParseReturnStatement() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x6e4bcb2)
#23 0x0000000006e4fbfd clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector&, clang::Parser::ParsedStmtContext, clang::SourceLocation*, clang::ParsedAttributes&, clang::ParsedAttributes&, clang::LabelDecl*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x6e4fbfd)
#24 0x0000000006e50da9 clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector&, clang::Parser::ParsedStmtContext, clang::SourceLocation*, clang::LabelDecl*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x6e50da9)
#25 0x0000000006e592a5 clang::Parser::ParseCompoundStatementBody(bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x6e592a5)
#26 0x0000000006e59aea clang::Parser::ParseFunctionStatementBody(clang::Decl*, clang::Parser::ParseScope&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x6e59aea)
#27 0x0000000006d57cfd clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&, clang::Parser::ParsedTemplateInfo const&, clang::LateParsedAttrList*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x6d57cfd)
#28 0x0000000006da1626 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+0x6da1626)
#29 0x0000000006d4c14b clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x6d4c14b)
#30 0x0000000006d4c92f clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x6d4c92f)
#31 0x0000000006d590d8 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x6d590d8)
#32 0x0000000006d5a035 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x6d5a035)
#33 0x0000000006d5a420 clang::Parser::ParseFirstTopLevelDecl(clang::OpaquePtr&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x6d5a420)
#34 0x0000000006d36f7c clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x6d36f7c)
#35 0x0000000004f22898 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4f22898)
#36 0x000000000524f388 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x524f388)
#37 0x00000000051dc59d clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x51dc59d)
#38 0x0000000005324c5d clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5324c5d)
#39 0x0000000000dadaec cc1_main(llvm::ArrayRef, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xdadaec)
#40 0x0000000000da470a ExecuteCC1Tool(llvm::SmallVectorImpl&, llvm::ToolContext const&, llvm::IntrusiveRefCntPtr) driver.cpp:0:0
#41 0x0000000000da488d int llvm::function_ref&)>::callback_fn&)>(long, llvm::SmallVectorImpl&) driver.cpp:0:0
#42 0x0000000004f9b379 void llvm::function_ref::callback_fn>, std::__cxx11::basic_string, std::allocator>*, bool*) const::'lambda'()>(long) Job.cpp:0:0
#43 0x000000000436b774 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x436b774)
#44 0x0000000004f9bee5 clang::driver::CC1Command::Execute(llvm::ArrayRef>, std::__cxx11::basic_string, std::allocator>*, bool*) const (.part.0) Job.cpp:0:0
#45 0x0000000004f53db2 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4f53db2)
#46 0x0000000004f58717 clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl>&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4f58717)
#47 0x0000000004f62c85 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4f62c85)
#48 0x0000000000da9fea clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xda9fea)
#49 0x0000000000cc5c8a main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xcc5c8a)
#50 0x00007d09b6e2a1ca (/lib/x86_64-linux-gnu/libc.so.6+0x2a1ca)
#51 0x00007d09b6e2a28b __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2a28b)
#52 0x0000000000da40b5 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xda40b5)
clang: error: clang frontend command failed due to signal (use -v to see invocation)
Compiler returned: 134
```
Reproduced with:
```
clang 22.1.0, x86_64-unknown-linux-gnu, assertions enabled
clang 20.1.0, x86_64-unknown-linux-gnu, assertions enabled
```
Contributor guide
Research direction
Start by running the provided C reproducer, then inspect SemaChecking.cpp at BuiltinFPClassification and SemaExprCXX.cpp at PerformImplicitConversion, as identified by the backtrace. Trace the bad conversion path and confirm that the reproducer produces a diagnostic without triggering the assertion or crashing.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100