<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/111612>111612</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [clang++][crash on valid] clang crashed on llvm::BasicBlock::getDataLayout() const
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          yijan4845
      </td>
    </tr>
</table>

<pre>
    **This testcase is generated by a fuzzer.**

Compiler Explorer: [https://godbolt.org/z/oc6zG4Yo5](https://godbolt.org/z/oc6zG4Yo5)

This valid code will crash on both Clang Trunk and Clang Assertion Trunk, it seems that this goes back to clang 3.3:
```cpp
struct S {
 __attribute__((noreturn)) void operator=(S);
};

struct C {
  S b;
  float c;
  _Complex float e;
};

void a(C& x, C& y) {
 x = y;
}
```

Stack dump:
```
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 -fno-verbose-asm -S --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics <source>
1.      <eof> parser at end of file
2.      Per-file LLVM IR generation
3.      <source>:5:8: Generating code for declaration 'C::operator='
 #0 0x0000000003b9d598 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3b9d598)
 #1 0x0000000003b9b25c llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3b9b25c)
 #2 0x0000000003ae9a68 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #3 0x0000775f5f042520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #4 0x00000000033c8510 llvm::BasicBlock::getDataLayout() const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x33c8510)
 #5 0x0000000004362794 emitAddrOfFieldStorage(clang::CodeGen::CodeGenFunction&, clang::CodeGen::Address, clang::FieldDecl const*) CGExpr.cpp:0:0
 #6 0x0000000004364ce6 clang::CodeGen::CodeGenFunction::EmitLValueForField(clang::CodeGen::LValue, clang::FieldDecl const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4364ce6)
 #7 0x0000000004366780 clang::CodeGen::CodeGenFunction::EmitLValueForFieldInitialization(clang::CodeGen::LValue, clang::FieldDecl const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4366780)
 #8 0x00000000042f8397 (anonymous namespace)::FieldMemcpyizer::emitMemcpy() CGClass.cpp:0:0
 #9 0x00000000042f9199 clang::CodeGen::CodeGenFunction::emitImplicitAssignmentOperatorBody(clang::CodeGen::FunctionArgList&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x42f9199)
#10 0x0000000003f813bc clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3f813bc)
#11 0x0000000003fe981a clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3fe981a)
#12 0x0000000003fe4545 clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3fe4545)
#13 0x0000000003ff056d clang::CodeGen::CodeGenModule::EmitDeferred() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3ff056d)
#14 0x0000000003ff2683 clang::CodeGen::CodeGenModule::Release() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3ff2683)
#15 0x00000000044f5f6e (anonymous namespace)::CodeGeneratorImpl::HandleTranslationUnit(clang::ASTContext&) ModuleBuilder.cpp:0:0
#16 0x00000000044f3bc5 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x44f3bc5)
#17 0x0000000006620f3c clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6620f3c)
#18 0x00000000044f4378 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x44f4378)
#19 0x00000000047ae299 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x47ae299)
#20 0x000000000472cbde clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x472cbde)
#21 0x0000000004893b1e clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4893b1e)
#22 0x0000000000cd805f cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xcd805f)
#23 0x0000000000ccfd6a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#24 0x0000000004538049 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
#25 0x0000000003ae9f14 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3ae9f14)
#26 0x000000000453863f 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
#27 0x00000000044fdf7d clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x44fdf7d)
#28 0x00000000044ff06d 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+++0x44ff06d)
#29 0x0000000004506995 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4506995)
#30 0x0000000000cd4f2f clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xcd4f2f)
#31 0x0000000000ba49e4 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xba49e4)
#32 0x0000775f5f029d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#33 0x0000775f5f029e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#34 0x0000000000ccf81e _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xccf81e)
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/eJzkWlFz26gW_jXkhZFHBkmWHvKg2HFvd7KznTp3Z-6TByFks8WgAZTa_fV3ADk2Xifb9iY7O3M7bWMDOuf7Pg6HExAxhm8kY7cgvwP54oYMdqv07YH_QWRWZvlNo9rDLUA1QPXjlhtombGUGAa5gRsmmSaWtbA5QAK74ds3pidhMEgXIB3_n6tdzwXT8H7fC6WZBriGIL_bWtsbgGuAlgAtN6ptlLATpTcALb8BtFS0-PYh-4_KQb4AqPz-4ag6d-9xPxHBW0hVy-BXLgSkmpgtVBI2ym7hXBC5gY96kF8gke34vTaGacuVDD0AzSG30DC2M9BuiYXWWd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