<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/119207>119207</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[clang] Assertion `Info.Size > 0 && "Empty bitfield!"' failed.
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang:codegen,
crash-on-valid,
clang:frontend:fuzzer
</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/54GK88z8G](https://godbolt.org/z/54GK88z8G)
This valid code will crash on clang assertion trunk:
```cpp
enum E {
a = 1,
b = 2,
c = 3
};
struct S {
E e1 : (1 << 16);
};
E load(S *s) {
return s->e1;
}
```
It seems that this goes back to clang-3.5.
Stack dump:
```
clang++: /root/llvm-project/clang/lib/CodeGen/CGRecordLayoutBuilder.cpp:1208: std::unique_ptr<clang::CodeGen::CGRecordLayout> clang::CodeGen::CodeGenTypes::ComputeRecordLayout(const clang::RecordDecl*, llvm::StructType*): Assertion `Info.Size > 0 && "Empty bitfield!"' 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 <source>
1. <eof> parser at end of file
2. <source>:11:3: LLVM IR generation of declaration 'load'
3. <source>:11:3: Generating code for declaration 'load'
#0 0x0000000003c04df8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3c04df8)
#1 0x0000000003c02b04 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3c02b04)
#2 0x0000000003b50068 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#3 0x00007a13ff842520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#4 0x00007a13ff8969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
#5 0x00007a13ff842476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
#6 0x00007a13ff8287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
#7 0x00007a13ff82871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
#8 0x00007a13ff839e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#9 0x0000000003f597f3 clang::CodeGen::CodeGenTypes::ComputeRecordLayout(clang::RecordDecl const*, llvm::StructType*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3f597f3)
#10 0x00000000040a6fb5 clang::CodeGen::CodeGenTypes::ConvertRecordDeclType(clang::RecordDecl const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x40a6fb5)
#11 0x00000000040a824b clang::CodeGen::CodeGenTypes::getCGRecordLayout(clang::RecordDecl const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x40a824b)
#12 0x0000000003f108ff clang::CodeGen::CGDebugInfo::createBitFieldType(clang::FieldDecl const*, llvm::DIScope*, clang::RecordDecl const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3f108ff)
#13 0x0000000003f10f6a clang::CodeGen::CGDebugInfo::CollectRecordNormalField(clang::FieldDecl const*, unsigned long, llvm::DIFile*, llvm::SmallVectorImpl<llvm::Metadata*>&, llvm::DIType*, clang::RecordDecl const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3f10f6a)
#14 0x0000000003f11284 clang::CodeGen::CGDebugInfo::CollectRecordFields(clang::RecordDecl const*, llvm::DIFile*, llvm::SmallVectorImpl<llvm::Metadata*>&, llvm::DICompositeType*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3f11284)
#15 0x0000000003f157c7 clang::CodeGen::CGDebugInfo::CreateTypeDefinition(clang::RecordType const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3f157c7)
#16 0x0000000003f17e5b clang::CodeGen::CGDebugInfo::CreateType(clang::RecordType const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3f17e5b)
#17 0x0000000003f04691 clang::CodeGen::CGDebugInfo::CreateTypeNode(clang::QualType, llvm::DIFile*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3f04691)
#18 0x0000000003f04900 clang::CodeGen::CGDebugInfo::getOrCreateType(clang::QualType, llvm::DIFile*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3f04900)
#19 0x0000000003f1184c clang::CodeGen::CGDebugInfo::CreatePointerLikeType(llvm::dwarf::Tag, clang::Type const*, clang::QualType, llvm::DIFile*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3f1184c)
#20 0x0000000003f046e9 clang::CodeGen::CGDebugInfo::CreateTypeNode(clang::QualType, llvm::DIFile*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3f046e9)
#21 0x0000000003f04900 clang::CodeGen::CGDebugInfo::getOrCreateType(clang::QualType, llvm::DIFile*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3f04900)
#22 0x0000000003f12286 clang::CodeGen::CGDebugInfo::CreateType(clang::FunctionType const*, llvm::DIFile*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3f12286)
#23 0x0000000003f0467c clang::CodeGen::CGDebugInfo::CreateTypeNode(clang::QualType, llvm::DIFile*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3f0467c)
#24 0x0000000003f04900 clang::CodeGen::CGDebugInfo::getOrCreateType(clang::QualType, llvm::DIFile*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3f04900)
#25 0x0000000003f0ef39 clang::CodeGen::CGDebugInfo::getOrCreateFunctionType(clang::Decl const*, clang::QualType, llvm::DIFile*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3f0ef39)
#26 0x0000000003f18e44 clang::CodeGen::CGDebugInfo::emitFunctionStart(clang::GlobalDecl, clang::SourceLocation, clang::SourceLocation, clang::QualType, llvm::Function*, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3f18e44)
#27 0x0000000003feb6ae clang::CodeGen::CodeGenFunction::StartFunction(clang::GlobalDecl, clang::QualType, llvm::Function*, clang::CodeGen::CGFunctionInfo const&, clang::CodeGen::FunctionArgList const&, clang::SourceLocation, clang::SourceLocation) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3feb6ae)
#28 0x0000000003ff0ef5 clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3ff0ef5)
#29 0x000000000405871a clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x405871a)
#30 0x0000000004053995 clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4053995)
#31 0x0000000004053d7b clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4053d7b)
#32 0x000000000405e553 clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) (.part.0) CodeGenModule.cpp:0:0
#33 0x0000000004589ac6 (anonymous namespace)::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef) ModuleBuilder.cpp:0:0
#34 0x000000000457a7c8 clang::BackendConsumer::HandleTopLevelDecl(clang::DeclGroupRef) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x457a7c8)
#35 0x00000000065416e4 clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x65416e4)
#36 0x0000000004587678 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4587678)
#37 0x0000000004842f09 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4842f09)
#38 0x00000000047c2b9e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x47c2b9e)
#39 0x000000000492df6e clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x492df6e)
#40 0x0000000000cb235f cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xcb235f)
#41 0x0000000000ca9dfa ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#42 0x00000000045cb0d9 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 0x0000000003b50514 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3b50514)
#44 0x00000000045cb6cf 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 0x000000000459115d clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x459115d)
#46 0x000000000459224d 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+++0x459224d)
#47 0x0000000004599605 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4599605)
#48 0x0000000000caf1a3 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xcaf1a3)
#49 0x0000000000b82fe4 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xb82fe4)
#50 0x00007a13ff829d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#51 0x00007a13ff829e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#52 0x0000000000ca98a5 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xca98a5)
clang++: error: clang frontend command failed with exit code 134 (use -v to see invocation)
Compiler returned: 134
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzkW19zozj2_TTKiwoXiP8PeSCOnV_PLzPT207Nq0sI4TANEiuJdJJPvyUJG0PsJO6Ju2dnu9JVBqTLOedeXV2EwFJWG0bpJQivQHh9gTt1z8XlU_UnZkEShBc5L54uAcoAyu7uKwkVlYpgSWEl4YYyKrCiBcyfIIZl9_xMxcw2Bq7-m_OmrWoq4OKxrbmgAvgZBOHVvVKtBH4G0BKg5YYXOa_VjIsNQMtngJZhcPP_SfKc3IDwGqDk_c1Ram9ssD7guiog4QWF36q6hkRgeQ85g6TGbAOxlFSoijOoRMe-avtuBiLX_pG2BW5GWdfABQTxFXAzCDEE_jX0AJrrw9wcof4IEnPoayPxNfCvLBKpREcUXO1sLCD1oNEBJfrHHPhz6EUauu2z13kBa44LgJIVBCiTAKU7M4KqTjAoHeAvqDd03aNgbXxSUFLaSKjusYJKC7PhVMIck69QcSuG48_CmW2_UvpC0TX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