<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/132257>132257</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[clang] Crash with official test `/AST/ByteCode/builtin-bit-cast-bitfields.cpp` and extra base classes
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
Rush10233
</td>
</tr>
</table>
<pre>
Extended from [https://github.com/llvm/llvm-project/blob/main/clang/test/AST/ByteCode/builtin-bit-cast-bitfields.cpp](https://github.com/llvm/llvm-project/blob/main/clang/test/AST/ByteCode/builtin-bit-cast-bitfields.cpp).
The bug occurs when some extra base classes are added to the code(basically in line 186, 207, 336).
Please see [https://godbolt.org/z/G8aW9zYYa](https://godbolt.org/z/G8aW9zYYa)
Sorry for that I'm not sure actually which part is wrong.
Stack Dump:
```
0. Program arguments: /opt/compiler-explorer/clang-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. <source>:238:1: current parser token '}'
2. <source>:181:1: parsing namespace 'Classes'
#0 0x0000000003b7abe8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3b7abe8)
#1 0x0000000003b78d2c llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3b78d2c)
#2 0x0000000003ac85a8 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#3 0x00007403daa42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#4 0x00000000072f6fa0 (anonymous namespace)::APValueToBufferConverter::visit(clang::APValue const&, clang::QualType, clang::CharUnits) ExprConstant.cpp:0:0
#5 0x00000000072f66ac (anonymous namespace)::APValueToBufferConverter::visitRecord(clang::APValue const&, clang::QualType, clang::CharUnits) ExprConstant.cpp:0:0
#6 0x00000000072f6622 (anonymous namespace)::APValueToBufferConverter::visitRecord(clang::APValue const&, clang::QualType, clang::CharUnits) ExprConstant.cpp:0:0
#7 0x00000000072f6622 (anonymous namespace)::APValueToBufferConverter::visitRecord(clang::APValue const&, clang::QualType, clang::CharUnits) ExprConstant.cpp:0:0
#8 0x00000000072f72b1 (anonymous namespace)::APValueToBufferConverter::visit(clang::APValue const&, clang::QualType, clang::CharUnits) ExprConstant.cpp:0:0
#9 0x00000000072f8652 (anonymous namespace)::handleRValueToRValueBitCast((anonymous namespace)::EvalInfo&, clang::APValue&, clang::APValue const&, clang::CastExpr const*) (.part.0) ExprConstant.cpp:0:0
#10 0x000000000731e4ec (anonymous namespace)::handleLValueToRValueBitCast((anonymous namespace)::EvalInfo&, clang::APValue&, clang::APValue&, clang::CastExpr const*) ExprConstant.cpp:0:0
#11 0x0000000007376c66 (anonymous namespace)::IntExprEvaluator::VisitCastExpr(clang::CastExpr const*) ExprConstant.cpp:0:0
#12 0x0000000007348e80 clang::StmtVisitorBase<llvm::make_const_ptr, (anonymous namespace)::IntExprEvaluator, bool>::Visit(clang::Stmt const*) ExprConstant.cpp:0:0
#13 0x000000000730db6e Evaluate(clang::APValue&, (anonymous namespace)::EvalInfo&, clang::Expr const*) ExprConstant.cpp:0:0
#14 0x00000000073161bf EvaluateAsRValue((anonymous namespace)::EvalInfo&, clang::Expr const*, clang::APValue&) ExprConstant.cpp:0:0
#15 0x000000000731846f clang::Expr::isCXX11ConstantExpr(clang::ASTContext const&, clang::APValue*, clang::SourceLocation*) const (/opt/compiler-explorer/clang-trunk/bin/clang+++0x731846f)
#16 0x00000000073189e8 EvaluateCPlusPlus11IntegralConstantExpr(clang::ASTContext const&, clang::Expr const*, llvm::APSInt*, clang::SourceLocation*) ExprConstant.cpp:0:0
#17 0x000000000731bea6 clang::Expr::getIntegerConstantExpr(clang::ASTContext const&, clang::SourceLocation*) const (/opt/compiler-explorer/clang-trunk/bin/clang+++0x731bea6)
#18 0x0000000006364715 AnalyzeImplicitConversions(clang::Sema&, clang::Expr*, clang::SourceLocation, bool) (.constprop.0) SemaChecking.cpp:0:0
#19 0x000000000636636a clang::Sema::CheckCompletedExpr(clang::Expr*, clang::SourceLocation, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x636636a)
#20 0x0000000006714a54 clang::Sema::ActOnFinishFullExpr(clang::Expr*, clang::SourceLocation, bool, bool, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x6714a54)
#21 0x00000000065360d2 clang::Sema::BuildStaticAssertDeclaration(clang::SourceLocation, clang::Expr*, clang::Expr*, clang::SourceLocation, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x65360d2)
#22 0x000000000614177b clang::Parser::ParseStaticAssertDeclaration(clang::SourceLocation&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x614177b)
#23 0x000000000612fc9d clang::Parser::ParseDeclaration(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::ParsedAttributes&, clang::SourceLocation*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x612fc9d)
#24 0x00000000060e4f62 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x60e4f62)
#25 0x000000000614b134 clang::Parser::ParseInnerNamespace(llvm::SmallVector<clang::Parser::InnerNamespaceInfo, 4u> const&, unsigned int, clang::SourceLocation&, clang::ParsedAttributes&, clang::BalancedDelimiterTracker&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x614b134)
#26 0x000000000614bdab clang::Parser::ParseNamespace(clang::DeclaratorContext, clang::SourceLocation&, clang::SourceLocation) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x614bdab)
#27 0x000000000612fd57 clang::Parser::ParseDeclaration(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::ParsedAttributes&, clang::SourceLocation*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x612fd57)
#28 0x00000000060e4f62 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x60e4f62)
#29 0x00000000060e67d8 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x60e67d8)
#30 0x00000000060d4b5a clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x60d4b5a)
#31 0x00000000044f8d8d clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-trunk/bin/clang+++0x44f8d8d)
#32 0x00000000047ddc31 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-trunk/bin/clang+++0x47ddc31)
#33 0x000000000475c1bb clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x475c1bb)
#34 0x00000000048cddb3 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x48cddb3)
#35 0x0000000000d65be1 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0xd65be1)
#36 0x0000000000d5e3dd ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#37 0x0000000004546089 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
#38 0x0000000003ac89c3 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3ac89c3)
#39 0x00000000045462a9 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
#40 0x00000000045095cd clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-trunk/bin/clang+++0x45095cd)
#41 0x000000000450a591 clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/opt/compiler-explorer/clang-trunk/bin/clang+++0x450a591)
#42 0x000000000451492c clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x451492c)
#43 0x0000000000d629b1 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0xd629b1)
#44 0x0000000000c23264 main (/opt/compiler-explorer/clang-trunk/bin/clang+++0xc23264)
#45 0x00007403daa29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#46 0x00007403daa29e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#47 0x0000000000d5de75 _start (/opt/compiler-explorer/clang-trunk/bin/clang+++0xd5de75)
clang++: error: clang frontend command failed with exit code 139 (use -v to see invocation)
Compiler returned: 139
```
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzsWltz4zbS_TX0C0ouErzqwQ-0PMrn1Hwb79ibTZ5UINiUsAYBLgB65Pz6LYCUKVIXZ2aUpLLZVBwpxKXPOd1stAAQrdlaANx48a0X312R1mykuvnU6k3g4zC8KmT5evNha0CUUKJKyRp58e3GmEZ7Ye7hpYeXa2Y2bXFNZe3hJecvu49Zo-S_gBoPLwsuCw8va8KEh5eUE7H28NKAto3545OHl7evBhayBNu7ZdwwMSuYmVGijf1SMeClvqZ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