| Issue |
71250
|
| Summary |
[clang] Assertion in `getObjCEncodingForStructureImpl` with `[[no_unique_address]]` in Objective-C++ class
|
| Labels |
c++20,
clang:codegen,
crash-on-valid,
objective-c++
|
| Assignees |
|
| Reporter |
BertalanD
|
When compiling the following Objective-C++ code with an asserts build of `main` (c7a7a43db):
```objc++
struct Empty {};
struct Foo {
[[no_unique_address]] Empty m_empty;
long m_a;
long m_b;
};
@interface Bar {
Foo m_foo;
}
@end
@implementation Bar
@end
```
The following assertion below is triggered:
```
void clang::ASTContext::getObjCEncodingForStructureImpl(clang::RecordDecl*, std::string&, const clang::FieldDecl*, bool, clang::QualType*) const: Assertion `CurOffs <= CurLayObj->first' failed.
```
<details>
<summary>Complete backtrace</summary>
```console
clang++: /root/llvm-project/clang/lib/AST/ASTContext.cpp:8598: void clang::ASTContext::getObjCEncodingForStructureImpl(clang::RecordDecl*, std::string&, const clang::FieldDecl*, bool, clang::QualType*) const: Assertion `CurOffs <= CurLayObj->first' 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-snapshot -fcolor-diagnostics -fno-crash-diagnostics -x objective-c++ <source>
1. <eof> parser at end of file
2. <source>:11:17: LLVM IR generation of declaration 'Bar'
#0 0x0000000003778cf8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3778cf8)
#1 0x00000000037769bc llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x37769bc)
#2 0x00000000036bf368 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#3 0x00007f7dbf9ec420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
#4 0x00007f7dbf4af00b raise (/lib/x86_64-linux-gnu/libc.so.6+0x4300b)
#5 0x00007f7dbf48e859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x22859)
#6 0x00007f7dbf48e729 (/lib/x86_64-linux-gnu/libc.so.6+0x22729)
#7 0x00007f7dbf49ffd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)
#8 0x0000000006de73e7 clang::ASTContext::getObjCEncodingForStructureImpl(clang::RecordDecl*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&, clang::FieldDecl const*, bool, clang::QualType*) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6de73e7)
#9 0x0000000006de807e clang::ASTContext::getObjCEncodingForTypeImpl(clang::QualType, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&, clang::ASTContext::ObjCEncOptions, clang::FieldDecl const*, clang::QualType*) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6de807e)
#10 0x0000000003f2cb91 (anonymous namespace)::CGObjCGNU::GenerateClass(clang::ObjCImplementationDecl const*) CGObjCGNU.cpp:0:0
#11 0x0000000003b72f40 clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) (.part.0) CodeGenModule.cpp:0:0
#12 0x00000000049eb916 (anonymous namespace)::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef) ModuleBuilder.cpp:0:0
#13 0x00000000049dc9d8 clang::BackendConsumer::HandleTopLevelDecl(clang::DeclGroupRef) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x49dc9d8)
#14 0x0000000005efdd54 clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x5efdd54)
#15 0x00000000049e9208 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x49e9208)
#16 0x000000000424bdc9 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x424bdc9)
#17 0x00000000041cc4be clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x41cc4be)
#18 0x000000000432afce clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x432afce)
#19 0x0000000000bf5fd6 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xbf5fd6)
#20 0x0000000000bed89a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#21 0x0000000004027cc9 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
#22 0x00000000036bf814 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x36bf814)
#23 0x00000000040282bf 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
#24 0x0000000003ff0215 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3ff0215)
#25 0x0000000003ff0c7d 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+++0x3ff0c7d)
#26 0x0000000003ff8ba5 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3ff8ba5)
#27 0x0000000000bf347c clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xbf347c)
#28 0x0000000000aec0b1 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xaec0b1)
#29 0x00007f7dbf490083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#30 0x0000000000bed37e _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xbed37e)
clang++: error: clang frontend command failed with exit code 134 (use -v to see invocation)
```
</details>
Removing the two `long` member variables or moving the `[[no_unique_address]]` member from the C++ class to the ObjC class leads to successful compilation.
Godbolt link: https://godbolt.org/z/G35PvPP8j
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs