[clang] Assertion `FromType->isRecordType()' failed.
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
Reproducer:
https://godbolt.org/z/zb1qzoYvs
```cpp
struct S {};
constexpr S s;
struct SS {
consteval const S *operator->() const { return &s; }
consteval int foo() const { return 42; }
};
_Atomic SS ss;
int v = ss->bar;
int x = ss.foo();
```
Backtrace:
```console
clang++: /root/llvm-project/llvm/tools/clang/lib/Sema/SemaOverload.cpp:6146: clang::ImplicitConversionSequence TryObjectArgumentInitialization(clang::Sema&, clang::SourceLocation, clang::QualType, clang::Expr::Classification, clang::CXXMethodDecl*, const clang::CXXRecordDecl*, bool, clang::QualType, bool): Assertion `FromType->isRecordType()' 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 -std=c++20
1. :12:17: current parser token ';'
#0 0x0000000004364be8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4364be8)
#1 0x0000000004361b04 llvm::sys::RunSignalHandlers() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4361b04)
#2 0x0000000004362124 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4362124)
#3 0x00000000042a0328 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#4 0x00007e169e245330 (/lib/x86_64-linux-gnu/libc.so.6+0x45330)
#5 0x00007e169e29eb2c pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x9eb2c)
#6 0x00007e169e24527e raise (/lib/x86_64-linux-gnu/libc.so.6+0x4527e)
#7 0x00007e169e2288ff abort (/lib/x86_64-linux-gnu/libc.so.6+0x288ff)
#8 0x00007e169e22881b (/lib/x86_64-linux-gnu/libc.so.6+0x2881b)
#9 0x00007e169e23b517 (/lib/x86_64-linux-gnu/libc.so.6+0x3b517)
#10 0x000000000756f993 (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x756f993)
#11 0x000000000757cb86 clang::Sema::PerformImplicitObjectArgumentInitialization(clang::Expr*, clang::NestedNameSpecifier, clang::NamedDecl*, clang::CXXMethodDecl*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x757cb86)
#12 0x000000000758a144 clang::Sema::BuildCallToMemberFunction(clang::Scope*, clang::Expr*, clang::SourceLocation, llvm::MutableArrayRef, clang::SourceLocation, clang::Expr*, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x758a144)
#13 0x00000000071ddeda 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+++0x71ddeda)
#14 0x00000000071e38ef clang::Sema::ActOnCallExpr(clang::Scope*, clang::Expr*, clang::SourceLocation, llvm::MutableArrayRef, clang::SourceLocation, clang::Expr*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x71e38ef)
#15 0x0000000007252c06 clang::TreeTransform, llvm::PointerIntPairInfo>>*>)::ComplexRemove>::TransformCallExpr(clang::CallExpr*) SemaExpr.cpp:0:0
#16 0x00000000071b9396 clang::Sema::PopExpressionEvaluationContext() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x71b9396)
#17 0x0000000006c8916b clang::Parser::ParseDeclarationAfterDeclaratorAndAttributes(clang::Declarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::ForRangeInit*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6c8916b)
#18 0x0000000006ca8ac2 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+++0x6ca8ac2)
#19 0x0000000006c543eb clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6c543eb)
#20 0x0000000006c54bef clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6c54bef)
#21 0x0000000006c61411 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6c61411)
#22 0x0000000006c62325 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6c62325)
#23 0x0000000006c3ff3a clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6c3ff3a)
#24 0x0000000004e535d8 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4e535d8)
#25 0x000000000517dc68 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x517dc68)
#26 0x0000000005109b6d clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x5109b6d)
#27 0x000000000527f19d clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x527f19d)
#28 0x0000000000db9c7c cc1_main(llvm::ArrayRef, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xdb9c7c)
#29 0x0000000000db088a ExecuteCC1Tool(llvm::SmallVectorImpl&, llvm::ToolContext const&, llvm::IntrusiveRefCntPtr) driver.cpp:0:0
#30 0x0000000000db0a0d int llvm::function_ref&)>::callback_fn&)>(long, llvm::SmallVectorImpl&) driver.cpp:0:0
#31 0x0000000004ec6189 void llvm::function_ref::callback_fn>, std::__cxx11::basic_string, std::allocator>*, bool*) const::'lambda'()>(long) Job.cpp:0:0
#32 0x00000000042a0764 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x42a0764)
#33 0x0000000004ec6cb5 clang::driver::CC1Command::Execute(llvm::ArrayRef>, std::__cxx11::basic_string, std::allocator>*, bool*) const (.part.0) Job.cpp:0:0
#34 0x0000000004e82242 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4e82242)
#35 0x0000000004e8325e clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl>&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4e8325e)
#36 0x0000000004e8f3c5 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4e8f3c5)
#37 0x0000000000db616a clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xdb616a)
#38 0x0000000000ccb54a main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xccb54a)
#39 0x00007e169e22a1ca (/lib/x86_64-linux-gnu/libc.so.6+0x2a1ca)
#40 0x00007e169e22a28b __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2a28b)
#41 0x0000000000db0235 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xdb0235)
clang++: error: clang frontend command failed due to signal (use -v to see invocation)
Compiler returned: 134
```
Contributor guide
Research direction
Start with the C++ reproducer linked in the issue and inspect clang/lib/Sema/SemaOverload.cpp around TryObjectArgumentInitialization, where the assertion occurs. Re-run the reproducer with the reported C++20 command, then trace the member-call handling shown in the stack. Done means the reproducer no longer aborts on the assertion and has appropriate compiler behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100