-
Notifications
You must be signed in to change notification settings - Fork 15.4k
Closed
Copy link
Labels
clang:frontendLanguage frontend issues, e.g. anything involving "Sema"Language frontend issues, e.g. anything involving "Sema"confirmedVerified by a second partyVerified by a second partycrashPrefer [crash-on-valid] or [crash-on-invalid]Prefer [crash-on-valid] or [crash-on-invalid]
Description
This crash can be observed in both LLVM 18 and LLVM trunk versions.https://godbolt.org/z/v57annjGn
Command
clang++ bug.cpp
Code
template < typename T > struct A
{
enum E : T;
E h ();
};
A < int > a;
A < int >::E b = a.h () + 1;
int i = b.e ();
static_assert (i == 1, "i");
A::E e = b.e ();
static_assert (e, "");
A::E e = A::h () + 1;
template < typename T > enum A < T >::E : T { e };
template < typename T > typename A < T >::E A < T >::h ()
{
return e;
}Version
clang-18
Ubuntu clang version 18.1.8 (++20240731025011+3b5b5c1ec4a3-1~exp1~20240731145104.143)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/binError Output
Stack dump:
0. Program arguments: /usr/lib/llvm-18/bin/clang -cc1 -triple x86_64-pc-linux-gnu -emit-obj -mrelax-all -dumpdir a- -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name bug.cpp -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/home/bugs -fcoverage-compilation-dir=/home/bugs -resource-dir /usr/lib/llvm-18/lib/clang/18 -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/x86_64-linux-gnu/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/backward -internal-isystem /usr/lib/llvm-18/lib/clang/18/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -fdeprecated-macro -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -fcxx-exceptions -fexceptions -fcolor-diagnostics -dwarf-debug-flags "/usr/lib/llvm-18/bin/clang --driver-mode=g++ bug.cpp -dumpdir a-" -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/bug-2ab286.o -x c++ bug.cpp
1. bug.cpp:8:28: current parser token ';'
#0 0x00007fb2523ecb46 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/lib/x86_64-linux-gnu/libLLVM-18.so.18.1+0xd93b46)
#1 0x00007fb2523eaaf0 llvm::sys::RunSignalHandlers() (/lib/x86_64-linux-gnu/libLLVM-18.so.18.1+0xd91af0)
#2 0x00007fb2523ed210 (/lib/x86_64-linux-gnu/libLLVM-18.so.18.1+0xd94210)
#3 0x00007fb25123c090 (/lib/x86_64-linux-gnu/libc.so.6+0x43090)
#4 0x00007fb2598f2639 clang::ASTContext::getIntegerRank(clang::Type const*) const (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18.1+0xc9b639)
#5 0x00007fb2598f30c5 clang::ASTContext::getIntegerTypeOrder(clang::QualType, clang::QualType) const (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18.1+0xc9c0c5)
#6 0x00007fb25a2fcdf3 (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18.1+0x16a5df3)
#7 0x00007fb25a2fc132 clang::Sema::UsualArithmeticConversions(clang::ActionResult<clang::Expr*, true>&, clang::ActionResult<clang::Expr*, true>&, clang::SourceLocation, clang::Sema::ArithConvKind) (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18.1+0x16a5132)
#8 0x00007fb25a32095b clang::Sema::CheckAdditionOperands(clang::ActionResult<clang::Expr*, true>&, clang::ActionResult<clang::Expr*, true>&, clang::SourceLocation, clang::BinaryOperatorKind, clang::QualType*) (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18.1+0x16c995b)
#9 0x00007fb25a30de92 clang::Sema::CreateBuiltinBinOp(clang::SourceLocation, clang::BinaryOperatorKind, clang::Expr*, clang::Expr*) (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18.1+0x16b6e92)
#10 0x00007fb25a5f3d74 clang::Sema::CreateOverloadedBinOp(clang::SourceLocation, clang::BinaryOperatorKind, clang::UnresolvedSetImpl const&, clang::Expr*, clang::Expr*, bool, bool, clang::FunctionDecl*) (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18.1+0x199cd74)
#11 0x00007fb25a32cf2c (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18.1+0x16d5f2c)
#12 0x00007fb25a32cb10 clang::Sema::BuildBinOp(clang::Scope*, clang::SourceLocation, clang::BinaryOperatorKind, clang::Expr*, clang::Expr*) (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18.1+0x16d5b10)
#13 0x00007fb25a2fba9f clang::Sema::ActOnBinOp(clang::Scope*, clang::SourceLocation, clang::tok::TokenKind, clang::Expr*, clang::Expr*) (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18.1+0x16a4a9f)
#14 0x00007fb2598250a4 clang::Parser::ParseRHSOfBinaryExpression(clang::ActionResult<clang::Expr*, true>, clang::prec::Level) (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18.1+0xbce0a4)
#15 0x00007fb259823e8f clang::Parser::ParseAssignmentExpression(clang::Parser::TypeCastState) (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18.1+0xbcce8f)
#16 0x00007fb2597f44fe clang::Parser::ParseDeclarationAfterDeclaratorAndAttributes(clang::Declarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::ForRangeInit*) (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18.1+0xb9d4fe)
#17 0x00007fb2597f1884 clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::ParsedAttributes&, clang::SourceLocation*, clang::Parser::ForRangeInit*) (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18.1+0xb9a884)
#18 0x00007fb2598a6e7a clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18.1+0xc4fe7a)
#19 0x00007fb2598a6843 clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18.1+0xc4f843)
#20 0x00007fb2598a5aa6 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18.1+0xc4eaa6)
#21 0x00007fb2598a3eda clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18.1+0xc4ceda)
#22 0x00007fb2597dcc7e clang::ParseAST(clang::Sema&, bool, bool) (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18.1+0xb85c7e)
#23 0x00007fb25b614415 clang::FrontendAction::Execute() (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18.1+0x29bd415)
#24 0x00007fb25b58e674 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18.1+0x2937674)
#25 0x00007fb25b68e69e clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18.1+0x2a3769e)
#26 0x000055ecd5475c62 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/usr/lib/llvm-18/bin/clang+0x12c62)
#27 0x000055ecd5473095 (/usr/lib/llvm-18/bin/clang+0x10095)
#28 0x000055ecd5472256 clang_main(int, char**, llvm::ToolContext const&) (/usr/lib/llvm-18/bin/clang+0xf256)
#29 0x000055ecd547faf6 main (/usr/lib/llvm-18/bin/clang+0x1caf6)
#30 0x00007fb25121d083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#31 0x000055ecd546fb0e _start (/usr/lib/llvm-18/bin/clang+0xcb0e)clang-truck
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 -std=c++20 <source>
1. <source>:8:28: current parser token ';'
#0 0x00000000039bee18 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x39bee18)
#1 0x00000000039bcf64 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x39bcf64)
#2 0x000000000390d898 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#3 0x0000791d8a842520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#4 0x0000000007025f38 clang::ASTContext::getTypeInfoImpl(clang::Type const*) const (/opt/compiler-explorer/clang-trunk/bin/clang+++0x7025f38)
#5 0x00007ffcdfa753a0 Metadata
Metadata
Assignees
Labels
clang:frontendLanguage frontend issues, e.g. anything involving "Sema"Language frontend issues, e.g. anything involving "Sema"confirmedVerified by a second partyVerified by a second partycrashPrefer [crash-on-valid] or [crash-on-invalid]Prefer [crash-on-valid] or [crash-on-invalid]