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

    <tr>
        <th>Summary</th>
        <td>
            Clang-21 Crash: Assertion `!Info.isIncomplete() && "Access to an object of an incomplete type!"' failed.
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

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

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

<pre>
    ### Description
I encountered a crash in Clang-21 when compiling the following code with compilation options:
```c
enum E e;

void
foo (void)
{
  int a[e];
}
```
Options:
```sh
-Os -fno-stack-protector -march=atom -mno-sse2  
```

### Clang Version

```sh
$ clang -v
Ubuntu clang version 21.0.0 (++20250501082025+9b1051281e43-1~exp1~20250501082214.882)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/lib/llvm-21/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/11
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/13
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/13
Candidate multilib: .;@m64
Selected multilib: .;@m64
```

### Command
The compilation command used was:
```sh
clang bug.c -Os -fno-stack-protector -march=atom -mno-sse2  -c -o bug.o
```

### Error Message
```sh
clang: /root/llvm-project/llvm/tools/clang/lib/CodeGen/CodeGenTBAA.cpp:624: llvm::MDNode* clang::CodeGen::CodeGenTBAA::getAccessTagInfo(clang::CodeGen::TBAAAccessInfo): Assertion `!Info.isIncomplete() && "Access to an object of an incomplete type!"' 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 -fno-verbose-asm -S --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics -Os -fno-stack-protector -march=atom -mno-sse2 <source>
1.      <eof> parser at end of file
2.      <source>:4:1: LLVM IR generation of declaration 'foo'
3.      <source>:4:1: Generating code for declaration 'foo'
 #0 0x0000000003fdf498 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3fdf498)
 #1 0x0000000003fdd124 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3fdd124)
 #2 0x0000000003f21e88 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #3 0x00007f7a69842520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #4 0x00007f7a698969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
 #5 0x00007f7a69842476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
 #6 0x00007f7a698287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
 #7 0x00007f7a6982871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
 #8 0x00007f7a69839e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
 #9 0x00000000045f6f09 clang::CodeGen::CodeGenTBAA::getAccessTagInfo(clang::CodeGen::TBAAAccessInfo) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x45f6f09)
#10 0x000000000454ee70 clang::CodeGen::CodeGenModule::DecorateInstructionWithTBAA(llvm::Instruction*, clang::CodeGen::TBAAAccessInfo) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x454ee70)
#11 0x0000000004330033 clang::CodeGen::CodeGenFunction::EmitLoadOfScalar(clang::CodeGen::Address, bool, clang::QualType, clang::SourceLocation, clang::CodeGen::LValueBaseInfo, clang::CodeGen::TBAAAccessInfo, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4330033)
#12 0x0000000004331035 clang::CodeGen::CodeGenFunction::EmitLoadOfLValue(clang::CodeGen::LValue, clang::SourceLocation) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4331035)
#13 0x00000000043bc116 (anonymous namespace)::ScalarExprEmitter::EmitLoadOfLValue(clang::Expr const*) CGExprScalar.cpp:0:0
#14 0x00000000043b50d7 clang::StmtVisitorBase<std::add_pointer, (anonymous namespace)::ScalarExprEmitter, llvm::Value*>::Visit(clang::Stmt*) CGExprScalar.cpp:0:0
#15 0x00000000043b546b (anonymous namespace)::ScalarExprEmitter::Visit(clang::Expr*) CGExprScalar.cpp:0:0
#16 0x00000000043bc69b (anonymous namespace)::ScalarExprEmitter::VisitCastExpr(clang::CastExpr*) CGExprScalar.cpp:0:0
#17 0x00000000043b3661 clang::StmtVisitorBase<std::add_pointer, (anonymous namespace)::ScalarExprEmitter, llvm::Value*>::Visit(clang::Stmt*) CGExprScalar.cpp:0:0
#18 0x00000000043b91ac clang::CodeGen::CodeGenFunction::EmitScalarExpr(clang::Expr const*, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x43b91ac)
#19 0x000000000453b34f clang::CodeGen::CodeGenFunction::EmitVariablyModifiedType(clang::QualType) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x453b34f)
#20 0x00000000048ef088 clang::CodeGen::CodeGenFunction::EmitAutoVarAlloca(clang::VarDecl const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x48ef088)
#21 0x00000000048f33db clang::CodeGen::CodeGenFunction::EmitVarDecl(clang::VarDecl const&) (.part.0) CGDecl.cpp:0:0
#22 0x00000000048f3be7 clang::CodeGen::CodeGenFunction::EmitDecl(clang::Decl const&, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x48f3be7)
#23 0x00000000044b4cec clang::CodeGen::CodeGenFunction::EmitDeclStmt(clang::DeclStmt const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x44b4cec)
#24 0x00000000044cac92 clang::CodeGen::CodeGenFunction::EmitSimpleStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x44cac92)
#25 0x00000000044c25d1 clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x44c25d1)
#26 0x00000000044ca72c clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt const&, bool, clang::CodeGen::AggValueSlot) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x44ca72c)
#27 0x000000000453053e clang::CodeGen::CodeGenFunction::EmitFunctionBody(clang::Stmt const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x453053e)
#28 0x0000000004543814 clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4543814)
#29 0x00000000045adc6d clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x45adc6d)
#30 0x00000000045a8c84 clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x45a8c84)
#31 0x00000000045a9333 clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x45a9333)
#32 0x00000000045b3e53 clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) (.part.0) CodeGenModule.cpp:0:0
#33 0x0000000004998b76 (anonymous namespace)::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef) ModuleBuilder.cpp:0:0
#34 0x0000000004988654 clang::BackendConsumer::HandleTopLevelDecl(clang::DeclGroupRef) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4988654)
#35 0x000000000668c484 clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x668c484)
#36 0x0000000004994d08 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4994d08)
#37 0x0000000004c8ede5 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4c8ede5)
#38 0x0000000004c0c0ee clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4c0c0ee)
#39 0x0000000004d81149 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4d81149)
#40 0x0000000000dbc0cf cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xdbc0cf)
#41 0x0000000000db2cda ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#42 0x00000000049fbd59 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
#43 0x0000000003f22324 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3f22324)
#44 0x00000000049fc36f 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
#45 0x00000000049bdebd clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x49bdebd)
#46 0x00000000049bef4e 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+0x49bef4e)
#47 0x00000000049c7045 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x49c7045)
#48 0x0000000000db85df clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xdb85df)
#49 0x0000000000c3ba44 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xc3ba44)
#50 0x00007f7a69829d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#51 0x00007f7a69829e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#52 0x0000000000db2785 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xdb2785)
clang: error: clang frontend command failed with exit code 134 (use -v to see invocation)
Compiler returned: 134
```

The issue can also be reproduced on Compiler Explorer:https://godbolt.org/z/caj1vP5M3
Please let me know if you need any more details.
</pre>

<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzkW11z47hy_TXwC4oqEqT48eAHWrYns-XJTsaO8-gCgabEOyTBAkB_5OH-9hQAShRp2WN5NZubypZ3ygKBxjkHje4mBFOlqnULcI6WF2h5eUZ7vRHyfPNSJssgSJZJGp0Vgr-cIxK6H3wJismq05VokZ9_xdAy0bcaJHBMMZNUbXDV4lVN27VHAvy0gRYz0XRVXbVrrDeAS1HX4sl8YoIDfqr0ZuhBjVksrHWFwhz5OYp998OQn0PbN_gKAwovzCM_fxQVR35eCoERSe0nkplHiemAcdVqTNHyAtDychiUXO5bRX7-58Hp1Ab5ufenwl7ZCk9pyn56nRQamBYSew2VbIPCS6pFg73GdFFAMJ7ZNj876awm-B6kcuK9mg6RCDPbyXtEfv6fRd_qfmh5dMMwCRb-wjdsEblA5IL4ZOkv_cBPzW-IXGRF4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