Issue 53059
Summary `[[no_unique_address]]` on non-empty type combined with duplicated base class causes `Assertion `Offset >= Size' failed`
Labels new issue
Assignees
Reporter davidstone
    The following valid translation unit

```
struct base {
};

struct a : private base {
	int m0;
	short m1;
};

struct b : private base {
	[[no_unique_address]] a m2;
};

void f(b const &) {
}
```

causes clang to crash with

```
clang++: /root/llvm-project/clang/lib/CodeGen/CGRecordLayoutBuilder.cpp:802: void {anonymous}::CGRecordLowering::insertPadding(): Assertion `Offset >= Size' failed.
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.	Program arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/clang++ -g -o /app/output.s -mllvm --x86-asm-syntax=intel -S --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics <source>
1.	<eof> parser at end of file
2.	<source>:13:6: LLVM IR generation of declaration 'f'
3.	<source>:13:6: Generating code for declaration 'f'
 #0 0x000055700183f0bf PrintStackTraceSignalHandler(void*) Signals.cpp:0:0
 #1 0x000055700183cee0 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3a3cee0)
 #2 0x0000557001775728 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #3 0x00007f4ce0cc43c0 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x153c0)
 #4 0x00007f4ce079318b raise (/lib/x86_64-linux-gnu/libc.so.6+0x4618b)
 #5 0x00007f4ce0772859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x25859)
 #6 0x00007f4ce0772729 (/lib/x86_64-linux-gnu/libc.so.6+0x25729)
 #7 0x00007f4ce0783f36 (/lib/x86_64-linux-gnu/libc.so.6+0x36f36)
 #8 0x0000557001bd3cf0 (anonymous namespace)::CGRecordLowering::lower(bool) CGRecordLayoutBuilder.cpp:0:0
 #9 0x0000557001bd43b9 clang::CodeGen::CodeGenTypes::ComputeRecordLayout(clang::RecordDecl const*, llvm::StructType*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3dd43b9)
#10 0x0000557001cd6305 clang::CodeGen::CodeGenTypes::ConvertRecordDeclType(clang::RecordDecl const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3ed6305)
#11 0x0000557001cd908e clang::CodeGen::CodeGenTypes::ConvertType(clang::QualType) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3ed908e)
#12 0x0000557001cda5a9 clang::CodeGen::CodeGenTypes::ConvertTypeForMem(clang::QualType, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3eda5a9)
#13 0x0000557001cd9d2a clang::CodeGen::CodeGenTypes::ConvertType(clang::QualType) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3ed9d2a)
#14 0x0000557001d4ab71 (anonymous namespace)::X86_64ABIInfo::classifyArgumentType(clang::QualType, unsigned int, unsigned int&, unsigned int&, bool) const TargetInfo.cpp:0:0
#15 0x0000557001d4c580 (anonymous namespace)::X86_64ABIInfo::computeInfo(clang::CodeGen::CGFunctionInfo&) const TargetInfo.cpp:0:0
#16 0x0000557001e4f7da clang::CodeGen::CodeGenTypes::arrangeLLVMFunctionInfo(clang::CanQual<clang::Type>, bool, bool, llvm::ArrayRef<clang::CanQual<clang::Type> >, clang::FunctionType::ExtInfo, llvm::ArrayRef<clang::FunctionType::ExtParameterInfo>, clang::CodeGen::RequiredArgs) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x404f7da)
#17 0x0000557001e5051d arrangeLLVMFunctionInfo(clang::CodeGen::CodeGenTypes&, bool, llvm::SmallVectorImpl<clang::CanQual<clang::Type> >&, clang::CanQual<clang::FunctionProtoType>) CGCall.cpp:0:0
#18 0x0000557001e5f332 clang::CodeGen::CodeGenTypes::arrangeFunctionDeclaration(clang::FunctionDecl const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x405f332)
#19 0x0000557001c9874b clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3e9874b)
#20 0x0000557001c952c5 clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3e952c5)
#21 0x0000557001c95a73 clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3e95a73)
#22 0x0000557001c9cc32 clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) (.part.6751) CodeGenModule.cpp:0:0
#23 0x000055700285e8dd (anonymous namespace)::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef) ModuleBuilder.cpp:0:0
#24 0x00005570028531ce clang::BackendConsumer::HandleTopLevelDecl(clang::DeclGroupRef) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4a531ce)
#25 0x00005570037419c4 clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x59419c4)
#26 0x000055700285bbb8 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4a5bbb8)
#27 0x00005570021f65f1 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x43f65f1)
#28 0x00005570021921ea clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x43921ea)
#29 0x00005570022c5b83 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x44c5b83)
#30 0x0000556fff1df27c cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x13df27c)
#31 0x0000556fff1da619 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&) driver.cpp:0:0
#32 0x0000557002038145 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*, bool*) const::'lambda'()>(long) Job.cpp:0:0
#33 0x0000557001775d13 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3975d13)
#34 0x000055700203a4c6 clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*, bool*) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x423a4c6)
#35 0x000055700200f84a clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x420f84a)
#36 0x00005570020104df clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x42104df)
#37 0x000055700201878a clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x421878a)
#38 0x0000556fff103c8f main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x1303c8f)
#39 0x00007f4ce07740b3 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x270b3)
#40 0x0000556fff1da18a _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x13da18a)
clang-14: error: clang frontend command failed with exit code 134 (use -v to see invocation)
Compiler returned: 134
```

See it live: https://godbolt.org/z/ze5dzMbPo
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to