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

    <tr>
        <th>Summary</th>
        <td>
            Assertion `AllowOversized && "Elems are oversized"' failed.
        </td>
    </tr>

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

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

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

<pre>
    Attempting to compile below program using `clang-20` with option `-O0` triggers an assertion failure.

```cpp
struct {
  __CHAR16_TYPE__ s[2];
} a[] = { [0].s[0] = u'x', u"" };
```

This behavior can be verified by visiting the link: [https://godbolt.org/z/rxbaMdW5z](https://godbolt.org/z/rxbaMdW5z).

The crash is possibly similar to this closed issue [69979](https://github.com/llvm/llvm-project/issues/69979).

```
clang-20: /root/llvm-project/clang/lib/CodeGen/CGExprConstant.cpp:450: static llvm::Constant* {anonymous}::ConstantAggregateBuilder::buildFrom(clang::CodeGen::CodeGenModule&, llvm::ArrayRef<llvm::Constant*>, llvm::ArrayRef<clang::CharUnits>, clang::CharUnits, clang::CharUnits, bool, llvm::Type*, bool): Assertion `AllowOversized && "Elems are oversized"' 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-20240830/bin/clang-20 -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -dumpdir /app/output.s- -disable-free -clear-ast-before-backend -main-file-name example.c -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -fno-verbose-asm -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debug-info-kind=constructor -dwarf-version=4 -debugger-tuning=gdb -fdebug-compilation-dir=/app -fcoverage-compilation-dir=/app -resource-dir /opt/compiler-explorer/clang-assertions-trunk-20240830/lib/clang/20 -internal-isystem /opt/compiler-explorer/clang-assertions-trunk-20240830/lib/clang/20/include -internal-isystem /usr/local/include -internal-isystem /opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/15.0.0/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -fcolor-diagnostics -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/example-22d3a5.o -x c <source>
1.      <eof> parser at end of file
2.      <source>:1:1: LLVM IR generation of declaration 'struct (unnamed at <source>:1:1)'
3.      <source>:3:3: Generating code for declaration 'a'
 #0 0x0000000003b14a88 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk-20240830/bin/clang-20+0x3b14a88)
 #1 0x0000000003b121cc SignalHandler(int) Signals.cpp:0:0
 #2 0x0000761eeea42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #3 0x0000761eeea969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
 #4 0x0000761eeea42476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
 #5 0x0000761eeea287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
 #6 0x0000761eeea2871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
 #7 0x0000761eeea39e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
 #8 0x0000000003e40810 (anonymous namespace)::ConstantAggregateBuilder::buildFrom(clang::CodeGen::CodeGenModule&, llvm::ArrayRef<llvm::Constant*>, llvm::ArrayRef<clang::CharUnits>, clang::CharUnits, clang::CharUnits, bool, llvm::Type*, bool) CGExprConstant.cpp:0:0
 #9 0x0000000003e40e1f (anonymous namespace)::ConstStructBuilder::Finalize(clang::QualType) (.isra.0) CGExprConstant.cpp:0:0
#10 0x0000000003e4c26f (anonymous namespace)::ConstStructBuilder::BuildStruct(clang::CodeGen::ConstantEmitter&, clang::InitListExpr const*, clang::QualType) CGExprConstant.cpp:0:0
#11 0x0000000003e4aa6d clang::StmtVisitorBase<llvm::make_const_ptr, (anonymous namespace)::ConstExprEmitter, llvm::Constant*, clang::QualType>::Visit(clang::Stmt const*, clang::QualType) CGExprConstant.cpp:0:0
#12 0x0000000003e4aed4 clang::CodeGen::ConstantEmitter::tryEmitPrivate(clang::Expr const*, clang::QualType) (/opt/compiler-explorer/clang-assertions-trunk-20240830/bin/clang-20+0x3e4aed4)
#13 0x0000000003e49a46 (anonymous namespace)::ConstExprEmitter::EmitArrayInitialization(clang::InitListExpr const*, clang::QualType) (.isra.0) CGExprConstant.cpp:0:0
#14 0x0000000003e4a756 clang::StmtVisitorBase<llvm::make_const_ptr, (anonymous namespace)::ConstExprEmitter, llvm::Constant*, clang::QualType>::Visit(clang::Stmt const*, clang::QualType) CGExprConstant.cpp:0:0
#15 0x0000000003e4d339 clang::CodeGen::ConstantEmitter::tryEmitPrivateForVarInit(clang::VarDecl const&) (/opt/compiler-explorer/clang-assertions-trunk-20240830/bin/clang-20+0x3e4d339)
#16 0x0000000003e4d592 clang::CodeGen::ConstantEmitter::tryEmitForInitializer(clang::VarDecl const&) (/opt/compiler-explorer/clang-assertions-trunk-20240830/bin/clang-20+0x3e4d592)
#17 0x0000000003f33f4e clang::CodeGen::CodeGenModule::EmitGlobalVarDefinition(clang::VarDecl const*, bool) (/opt/compiler-explorer/clang-assertions-trunk-20240830/bin/clang-20+0x3f33f4e)
#18 0x0000000003f574d9 clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-assertions-trunk-20240830/bin/clang-20+0x3f574d9)
#19 0x0000000003f57b1b clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl) (/opt/compiler-explorer/clang-assertions-trunk-20240830/bin/clang-20+0x3f57b1b)
#20 0x0000000003f61edb clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) (.part.0) CodeGenModule.cpp:0:0
#21 0x0000000004430be1 (anonymous namespace)::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef) ModuleBuilder.cpp:0:0
#22 0x00000000044211b8 clang::BackendConsumer::HandleTopLevelDecl(clang::DeclGroupRef) (/opt/compiler-explorer/clang-assertions-trunk-20240830/bin/clang-20+0x44211b8)
#23 0x000000000653c6a4 clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk-20240830/bin/clang-20+0x653c6a4)
#24 0x000000000442e788 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk-20240830/bin/clang-20+0x442e788)
#25 0x00000000046bdc09 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk-20240830/bin/clang-20+0x46bdc09)
#26 0x00000000046411fe clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk-20240830/bin/clang-20+0x46411fe)
#27 0x00000000047a743e clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk-20240830/bin/clang-20+0x47a743e)
#28 0x0000000000ca876f cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk-20240830/bin/clang-20+0xca876f)
#29 0x0000000000ca19ba ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#30 0x0000000000ca52ee clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk-20240830/bin/clang-20+0xca52ee)
#31 0x0000000000b799c4 main (/opt/compiler-explorer/clang-assertions-trunk-20240830/bin/clang-20+0xb799c4)
#32 0x0000761eeea29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#33 0x0000761eeea29e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#34 0x0000000000ca146e _start (/opt/compiler-explorer/clang-assertions-trunk-20240830/bin/clang-20+0xca146e)
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsWl1zmzq3_jXKjUYeEBibi1w4cdzdmXZ2T5PTPefKI8QCa0dIjCTy0V9_RgK7hjrZSXc95-K8ndoBIa31PEvrCzCzVtQK4BLNr9B8fcE6t9Pm8ln8zVS6TOcXhS6fL1fOQdM6oWrsNOa6aYUEXIDUj7g1ujaswZ31l1EWcclUTWiEsgg_CrfDunVCK3-J_BlGnRF1DcZipjCzFky4XjEhOwMzFK1RtBq-s6j_z9u2H7HOdNxhtLjqzzHebq__WH2Ns-3d_3y52W6xRfMriuZrlAxT0GKNWc8Po2Tt12I0v4rQfD2zw0G40CG6eEJ0gei1P6aIUowWR4L2aI4h3u2ExQXs2IPQBnOmcAH4AYyoBJS4eMYPworedDvAUqh7lKy8_p1zrUXJCtENoptal4WWbqZNjejmO6Ib81Swz-Vf8--eC12-fTrNZ2OAgLlhdoeFxa22VhTyGVvRCMmM30_nGXCpLZRYWNuBR5fl-SI_qVm4XVfMuG4Q3Uj5sP9DWqP_Bu4Q3QQhFtFNL2SCZ2LFg7t4q9CN0dr9LDFM8sOiQHRzrUv4AMoffbh5as21VtYx5WbeS5JVOg_CrGNOcBwgJiuUrPbTEF15H2BKq-dGdzZs8fGEVV0bqJmDq07IEkx_tfAnG-N5L3s8w6IezPHJZ112EhDNvCf9ALAyhj1_hQol1ydRoeTmxQXHGnfM_LcSzg7zT156ZbzQWo713D234PUfLubegKtDaKIsWkmpH_98AGPFdyhx4JZhROmNhMZiZgDr_dUQOosQ0FAOe__l083q9gbbrmiEwwwXXY0NtNo474K_7mKYqRILxWVXQoiw3tULxu-dYRw8p9ZAazQH6z3c6s70w34ls1ZzwRyU2HQKW25E6wbIt47xe1x2jXeqfiiaoSj_MmQ8ZuquAeX3IbiuboOr9tnREHhqpTZg9u5LDqnOEmc6dU9oR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