[clang] Assertion `!MemberQuals.hasAddressSpace()' failed.
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
Reproducer:
https://godbolt.org/z/7xze8oMfa
```cpp
struct S {
int x = 42;
S [[clang::address_space(1)]] s;
} s;
auto [a, b] = s;
```
Backtrace:
```console
clang++: /root/llvm-project/llvm/tools/clang/lib/Sema/SemaExprMember.cpp:1848: clang::ExprResult clang::Sema::BuildFieldReferenceExpr(clang::Expr*, bool, clang::SourceLocation, const clang::CXXScopeSpec&, clang::FieldDecl*, clang::DeclAccessPair, const clang::DeclarationNameInfo&): Assertion `!MemberQuals.hasAddressSpace()' 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. :6:16: current parser token ';'
#0 0x00000000044bbd48 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x44bbd48)
#1 0x00000000044b8fa4 llvm::sys::RunSignalHandlers() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x44b8fa4)
#2 0x00000000044b95dc llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x44b95dc)
#3 0x00000000043f5b38 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#4 0x0000798cfe845330 (/lib/x86_64-linux-gnu/libc.so.6+0x45330)
#5 0x0000798cfe89ec0c pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x9ec0c)
#6 0x0000798cfe84527e raise (/lib/x86_64-linux-gnu/libc.so.6+0x4527e)
#7 0x0000798cfe8288ff abort (/lib/x86_64-linux-gnu/libc.so.6+0x288ff)
#8 0x0000798cfe82881b (/lib/x86_64-linux-gnu/libc.so.6+0x2881b)
#9 0x0000798cfe83b517 (/lib/x86_64-linux-gnu/libc.so.6+0x3b517)
#10 0x00000000074c3ce8 clang::Sema::BuildFieldReferenceExpr(clang::Expr*, bool, clang::SourceLocation, clang::CXXScopeSpec const&, clang::FieldDecl*, clang::DeclAccessPair, clang::DeclarationNameInfo const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x74c3ce8)
#11 0x000000000730450a clang::Sema::CheckCompleteDecompositionDeclaration(clang::DecompositionDecl*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x730450a)
#12 0x0000000007238ac5 clang::Sema::CheckCompleteVariableDeclaration(clang::VarDecl*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x7238ac5)
#13 0x000000000724cf6a clang::Sema::AddInitializerToDecl(clang::Decl*, clang::Expr*, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x724cf6a)
#14 0x0000000006e5d3f1 clang::Parser::ParseDeclarationAfterDeclaratorAndAttributes(clang::Declarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::ForRangeInit*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6e5d3f1)
#15 0x0000000006e7d289 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+++0x6e7d289)
#16 0x0000000006e2839b clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6e2839b)
#17 0x0000000006e28b8f clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6e28b8f)
#18 0x0000000006e355f8 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6e355f8)
#19 0x0000000006e36535 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6e36535)
#20 0x0000000006e12a2a clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6e12a2a)
#21 0x0000000004fd0ef8 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4fd0ef8)
#22 0x00000000052f2568 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x52f2568)
#23 0x000000000528017d clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x528017d)
#24 0x00000000053c6d8d clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x53c6d8d)
#25 0x0000000000d9100c cc1_main(llvm::ArrayRef, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xd9100c)
#26 0x0000000000d87d1a ExecuteCC1Tool(llvm::SmallVectorImpl&, llvm::ToolContext const&, llvm::IntrusiveRefCntPtr) driver.cpp:0:0
#27 0x0000000000d87e9d int llvm::function_ref&)>::callback_fn&)>(long, llvm::SmallVectorImpl&) driver.cpp:0:0
#28 0x00000000050451c9 void llvm::function_ref::callback_fn>, std::__cxx11::basic_string, std::allocator>*, bool*) const::'lambda'()>(long) Job.cpp:0:0
#29 0x00000000043f5f34 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x43f5f34)
#30 0x0000000005045d35 clang::driver::CC1Command::Execute(llvm::ArrayRef>, std::__cxx11::basic_string, std::allocator>*, bool*) const (.part.0) Job.cpp:0:0
#31 0x0000000005004162 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x5004162)
#32 0x0000000005008ac7 clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl>&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x5008ac7)
#33 0x0000000005013025 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x5013025)
#34 0x0000000000d8d50a clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xd8d50a)
#35 0x0000000000ccb0ea main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xccb0ea)
#36 0x0000798cfe82a1ca (/lib/x86_64-linux-gnu/libc.so.6+0x2a1ca)
#37 0x0000798cfe82a28b __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2a28b)
#38 0x0000000000d876c5 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xd876c5)
clang++: error: clang frontend command failed due to signal (use -v to see invocation)
Program terminated with signal SIGABRT (6)
Compiler returned: 134
```
Contributor guide
Research direction
Compile the linked C++ reproducer and inspect clang/lib/Sema/SemaExprMember.cpp at BuildFieldReferenceExpr, then follow the CheckCompleteDecompositionDeclaration frame from the backtrace. Determine how this structured binding reaches the assertion and add regression coverage; done means the reproducer no longer aborts in clang.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 64/100