<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/89547>89547</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
`[[no_unique_address]]` crash
</td>
</tr>
<tr>
<th>Labels</th>
<td>
c++20,
clang:codegen,
confirmed,
crash-on-valid
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
Endilll
</td>
</tr>
</table>
<pre>
While reducing #88077, I stumbled upon the following segfault in CodeGen (https://godbolt.org/z/7TE6jdbEr):
```cpp
void *operator new(unsigned long, void *);
struct set_value_t {};
template <class Ty>
struct _box {
[[no_unique_address]] Ty _value;
};
struct _tuple {
_box<set_value_t> a;
};
void f()
{
int _storage[1];
new (_storage) _tuple{};
}
```
```
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 <source>
1. <eof> parser at end of file
2. <source>:14:6: LLVM IR generation of declaration 'f'
3. <source>:14:6: Generating code for declaration 'f'
#0 0x0000000003945d28 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3945d28)
#1 0x0000000003943a0c llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3943a0c)
#2 0x0000000003889f78 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#3 0x00007f0e2c642520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#4 0x000000000328787e llvm::Instruction::eraseFromParent() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x328787e)
#5 0x0000000004096381 (anonymous namespace)::AggExprEmitter::VisitCXXParenListOrInitListExpr(clang::Expr*, llvm::ArrayRef<clang::Expr*>, clang::FieldDecl*, clang::Expr*) CGExprAgg.cpp:0:0
#6 0x0000000004090847 (anonymous namespace)::AggExprEmitter::Visit(clang::Expr*) CGExprAgg.cpp:0:0
#7 0x0000000004090f8f clang::CodeGen::CodeGenFunction::EmitAggExpr(clang::Expr const*, clang::CodeGen::AggValueSlot) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4090f8f)
#8 0x0000000004099aaa StoreAnyExprIntoOneUnit(clang::CodeGen::CodeGenFunction&, clang::Expr const*, clang::QualType, clang::CodeGen::Address, clang::CodeGen::AggValueSlot::Overlap_t) (.constprop.0) CGExprCXX.cpp:0:0
#9 0x00000000040a5a7d clang::CodeGen::CodeGenFunction::EmitCXXNewExpr(clang::CXXNewExpr const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x40a5a7d)
#10 0x00000000040cae1c clang::StmtVisitorBase<std::add_pointer, (anonymous namespace)::ScalarExprEmitter, llvm::Value*>::Visit(clang::Stmt*) CGExprScalar.cpp:0:0
#11 0x00000000040cff5c clang::CodeGen::CodeGenFunction::EmitScalarExpr(clang::Expr const*, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x40cff5c)
#12 0x000000000406086e clang::CodeGen::CodeGenFunction::EmitAnyExpr(clang::Expr const*, clang::CodeGen::AggValueSlot, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x406086e)
#13 0x00000000040828a1 clang::CodeGen::CodeGenFunction::EmitIgnoredExpr(clang::Expr const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x40828a1)
#14 0x0000000003c6f195 clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3c6f195)
#15 0x0000000003c75a5c clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt const&, bool, clang::CodeGen::AggValueSlot) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3c75a5c)
#16 0x0000000003cd8405 clang::CodeGen::CodeGenFunction::EmitFunctionBody(clang::Stmt const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3cd8405)
#17 0x0000000003cebddc clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3cebddc)
#18 0x0000000003d4b442 clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3d4b442)
#19 0x0000000003d45cf5 clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3d45cf5)
#20 0x0000000003d46cd0 clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3d46cd0)
#21 0x0000000003d50873 clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) (.part.0) CodeGenModule.cpp:0:0
#22 0x00000000041f8ad6 (anonymous namespace)::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef) ModuleBuilder.cpp:0:0
#23 0x00000000041e9558 clang::BackendConsumer::HandleTopLevelDecl(clang::DeclGroupRef) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x41e9558)
#24 0x00000000061f9b04 clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x61f9b04)
#25 0x00000000041f65e8 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x41f65e8)
#26 0x0000000004476a39 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4476a39)
#27 0x00000000043ff83e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x43ff83e)
#28 0x0000000004559e1e clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4559e1e)
#29 0x0000000000c48e3c cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xc48e3c)
#30 0x0000000000c420ca ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#31 0x0000000004239609 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
#32 0x000000000388a424 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x388a424)
#33 0x0000000004239bff 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
#34 0x00000000041fff35 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x41fff35)
#35 0x000000000420099d 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+++0x420099d)
#36 0x0000000004208725 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4208725)
#37 0x0000000000c462d5 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xc462d5)
#38 0x0000000000b28da4 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xb28da4)
#39 0x00007f0e2c629d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#40 0x00007f0e2c629e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#41 0x0000000000c41bbe _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xc41bbe)
clang++: error: clang frontend command failed with exit code 139 (use -v to see invocation)
Compiler returned: 139
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzkWt9z3CgS_mvkF2pcEvr94Ifx2M55K3vJxb5s3qYQtGQ2DOgAOeP766-QNB4hj-045dm7qtvaJCPUNN_3dQMtJGIMbyTAWZCeB-nFCensndJnl5JxIcRJpdjD2R93XADSwDrKZYMCHBdFmOcBXqFrZGy3qQQw1LVKInsHqFZCqB_O0kBTk05YxCVaKQYfQKIAF3fWtiaIlwG-CvBVo1ilhD1Vugnw1b8DfJXfXmZ_supSB7h0ZuFFEC6DLBz-p207tNwrzlCAl6oFTazSSMKPABed7BkxJJRsHMadXe_tfPTW_22s7qhFBuz6nogO1hYF-XmQX8zsLGxaQSygIF5RQYxBtw9BfOk5WVdq2_fuGxHq9TyXat1J_q8O1oQxDcYE6UWQXqDbBzQMuR_pyag7x7ZrBUxdu6GCeDWBHcSXiLzgqpegDnDhNBhtHt1xadHaWKVJA0F6HjmI8eNdCT9czB4NcDkimiuVX8wCdfDy88fL5c0lMl214RYRVHUN0tAqbZFVaJYZ3N511SlVmwBfCXG_-2fRavUnUBvgK25MBybAV4hIhrikomPQZyHVxNyhitDvVhMKLhFaDa1WFIwBhozq9NDsehJjFOXEAkO6k8hQzVt7OkC-sYR-R6zbtI_JGJ4GYflZq0aTDSK66TYgrQOOAnylWoeMqk3LBegFbFuhNGjXJohsFsQY0JYraRZWd_J7gK8qLne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