Issue 239057
Summary [clang] Assertion `isFloat() && "Invalid accessor"' failed.
Labels clang:frontend, crash, generated by fuzzer
Assignees
Reporter k-arrows
    Reproducer:
https://godbolt.org/z/nsG7aY8PT
```cpp
template <typename T, typename U> struct S {
  static constexpr T t = 0;
  static constexpr U u = __builtin_choose_expr(sizeof(T) == sizeof(U), t, u);
};

template struct S<int, double>;
```

Backtrace:
```console
clang++: /root/llvm-project/llvm/tools/clang/include/clang/AST/APValue.h:588: clang::APValue::APFloat& clang::APValue::getFloat(): Assertion `isFloat() && "Invalid accessor"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace and dumped files.
Stack dump:
0.	Program arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/clang++ -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>:6:31: current parser token ';'
2.	<source>:3:22: instantiating variable definition 'S<int, double>::u'
 #0 0x0000000004efbef8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4efbef8)
 #1 0x0000000004ef9154 llvm::sys::RunSignalHandlers() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4ef9154)
 #2 0x0000000004ef978c llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4ef978c)
 #3 0x0000000004e33508 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #4 0x0000744264645330 (/lib/x86_64-linux-gnu/libc.so.6+0x45330)
 #5 0x000074426469ec0c pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x9ec0c)
 #6 0x000074426464527e raise (/lib/x86_64-linux-gnu/libc.so.6+0x4527e)
 #7 0x00007442646288ff abort (/lib/x86_64-linux-gnu/libc.so.6+0x288ff)
 #8 0x000074426462881b (/lib/x86_64-linux-gnu/libc.so.6+0x2881b)
 #9 0x000074426463b517 (/lib/x86_64-linux-gnu/libc.so.6+0x3b517)
#10 0x000000000a354063 (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xa354063)
#11 0x000000000a408f5e (anonymous namespace)::FloatExprEvaluator::VisitCastExpr(clang::CastExpr const*) ExprConstant.cpp:0:0
#12 0x000000000a3c758b clang::StmtVisitorBase<llvm::make_const_ptr, (anonymous namespace)::FloatExprEvaluator, bool>::Visit(clang::Stmt const*) ExprConstant.cpp:0:0
#13 0x000000000a3c9268 EvaluateFloat(clang::Expr const*, llvm::APFloat&, (anonymous namespace)::EvalInfo&) ExprConstant.cpp:0:0
#14 0x000000000a3979c4 Evaluate(clang::APValue&, (anonymous namespace)::EvalInfo&, clang::Expr const*) ExprConstant.cpp:0:0
#15 0x000000000a3d3d8b EvaluateInPlace(clang::APValue&, (anonymous namespace)::EvalInfo&, (anonymous namespace)::LValue const&, clang::Expr const*, bool) (.part.0) ExprConstant.cpp:0:0
#16 0x000000000a400f0d doEvaluateInitializer(clang::ASTContext const&, clang::SemaProxy*, clang::VarDecl const*, clang::Expr const*, clang::Expr::EvalResult&, bool) ExprConstant.cpp:0:0
#17 0x000000000a4013b3 clang::Expr::EvaluateAsMandatedConstantInitializer(clang::Expr::EvalResult&, clang::ASTContext const&, clang::SemaProxy&, clang::VarDecl const*) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xa4013b3)
#18 0x000000000a1f4b29 clang::VarDecl::evaluateValueImpl(llvm::SmallVectorImpl<std::pair<clang::SourceLocation, clang::PartialDiagnostic>>*, clang::SemaProxy*, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xa1f4b29)
#19 0x000000000a1f4cce clang::VarDecl::checkForConstantInitialization(llvm::SmallVectorImpl<std::pair<clang::SourceLocation, clang::PartialDiagnostic>>&, clang::SemaProxy&) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xa1f4cce)
#20 0x00000000093afcc5 clang::Sema::CheckCompleteVariableDeclaration(clang::VarDecl*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x93afcc5)
#21 0x00000000093b9c09 clang::Sema::AddInitializerToDecl(clang::Decl*, clang::Expr*, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x93b9c09)
#22 0x0000000009bd1210 clang::Sema::InstantiateVariableInitializer(clang::VarDecl*, clang::VarDecl*, clang::MultiLevelTemplateArgumentList const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x9bd1210)
#23 0x0000000009c2c383 clang::Sema::InstantiateVariableDefinition(clang::SourceLocation, clang::VarDecl*, bool, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x9c2c383)
#24 0x0000000009ba8f2c clang::Sema::InstantiateClassMembers(clang::SourceLocation, clang::CXXRecordDecl*, clang::MultiLevelTemplateArgumentList const&, clang::TemplateSpecializationKind) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x9ba8f2c)
#25 0x0000000009ba93b7 clang::Sema::InstantiateClassTemplateSpecializationMembers(clang::SourceLocation, clang::ClassTemplateSpecializationDecl*, clang::TemplateSpecializationKind) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x9ba93b7)
#26 0x0000000009a1a172 clang::Sema::ActOnExplicitInstantiation(clang::Scope*, clang::SourceLocation, clang::SourceLocation, unsigned int, clang::SourceLocation, clang::CXXScopeSpec const&, clang::OpaquePtr<clang::TemplateName>, clang::SourceLocation, clang::SourceLocation, llvm::MutableArrayRef<clang::ParsedTemplateArgument>, clang::SourceLocation, clang::ParsedAttributesView const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x9a1a172)
#27 0x0000000008fffb46 clang::Parser::ParseClassSpecifier(clang::tok::TokenKind, clang::SourceLocation, clang::DeclSpec&, clang::Parser::ParsedTemplateInfo&, clang::AccessSpecifier, bool, clang::Parser::DeclSpecContext, clang::ParsedAttributes&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x8fffb46)
#28 0x0000000008fce33a clang::Parser::ParseDeclarationSpecifiers(clang::DeclSpec&, clang::Parser::ParsedTemplateInfo&, clang::AccessSpecifier, clang::Parser::DeclSpecContext, clang::LateParsedAttrList*, clang::ImplicitTypenameContext) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x8fce33a)
#29 0x00000000090aa7c1 clang::Parser::ParseDeclarationAfterTemplate(clang::DeclaratorContext, clang::Parser::ParsedTemplateInfo&, clang::ParsingDeclRAIIObject&, clang::SourceLocation&, clang::ParsedAttributes&, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x90aa7c1)
#30 0x00000000090ab36c clang::Parser::ParseExplicitInstantiation(clang::DeclaratorContext, clang::SourceLocation, clang::SourceLocation, clang::SourceLocation&, clang::ParsedAttributes&, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x90ab36c)
#31 0x00000000090b8528 clang::Parser::ParseDeclarationStartingWithTemplate(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x90b8528)
#32 0x0000000008fe2510 clang::Parser::ParseDeclaration(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::ParsedAttributes&, clang::SourceLocation*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x8fe2510)
#33 0x0000000008f96600 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x8f96600)
#34 0x0000000008f974d5 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x8f974d5)
#35 0x0000000008f734ca clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x8f734ca)
#36 0x00000000059f69b8 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x59f69b8)
#37 0x0000000005d1eb68 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x5d1eb68)
#38 0x0000000005cab5dd clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x5cab5dd)
#39 0x0000000005df51c3 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x5df51c3)
#40 0x0000000001714be8 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x1714be8)
#41 0x000000000170baca ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>) driver.cpp:0:0
#42 0x000000000170bc53 int llvm::function_ref<int (llvm::SmallVectorImpl<char const*>&)>::callback_fn<clang_main(int, char**, llvm::ToolContext const&)::'lambda'(llvm::SmallVectorImpl<char const*>&)>(long, llvm::SmallVectorImpl<char const*>&) driver.cpp:0:0
#43 0x0000000005a6e949 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
#44 0x0000000004e33904 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4e33904)
#45 0x0000000005a6f4b5 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
#46 0x0000000005a2c2d2 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x5a2c2d2)
#47 0x0000000005a2f58c 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+++0x5a2f58c)
#48 0x0000000005a3ba85 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x5a3ba85)
#49 0x000000000171121a clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x171121a)
#50 0x0000000001686963 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x1686963)
#51 0x000074426462a1ca (/lib/x86_64-linux-gnu/libc.so.6+0x2a1ca)
#52 0x000074426462a28b __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2a28b)
#53 0x000000000170b475 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x170b475)
clang++: error: clang frontend command failed due to signal (use -v to see invocation)
Program terminated with signal SIGABRT (6)
Compiler returned: 134
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to