-
Notifications
You must be signed in to change notification settings - Fork 12.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ICE in clang since 3.5 to trunk in c++14 mode (and up) #75847
Comments
@llvm/issue-subscribers-clang-frontend Author: Hana Dusíková (hanickadot)
https://compiler-explorer.com/z/vfvqd941z
minimized reproducer: template <typename T> struct array {
T data[1]{};
};
template <typename Target> struct helper {
template <unsigned> static constexpr auto pointer = &Target::select;
constexpr int populate() {
array<decltype(pointer<0>)>{};
return 0;
}
};
struct jump_table {
void select() {}
static constexpr auto pointers = helper<jump_table>().populate();
};
|
Confirmed. |
a slight simplification leads to reject valid template <typename Target> struct helper {
template <unsigned> static constexpr auto pointer = &Target::select;
constexpr int populate() {
decltype(pointer<0>){};
return 0;
}
};
struct jump_table {
void select() {}
};
static auto pointers = helper<jump_table>().populate(); We do try to initialize If you use pointer<0> in an evaluated context, it is correctly instantiated |
Simpler test case: template <typename> struct helper {
template <unsigned> static constexpr auto i = 0;
};
constexpr auto i = sizeof helper<void>::i<0>; Assertion: clang++: /root/llvm-project/clang/lib/AST/ASTContext.cpp:2415:
clang::TypeInfo clang::ASTContext::getTypeInfoImpl(const clang::Type*) const:
Assertion `!A->getDeducedType().isNull() && "cannot request the size of an undeduced or dependent auto type"' failed. 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. <source>:5:45: current parser token ';'
#0 0x0000000003c56d58 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3c56d58)
#1 0x0000000003c54a64 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3c54a64)
#2 0x0000000003ba1fc8 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#3 0x00007df6db642520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#4 0x00007df6db6969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
#5 0x00007df6db642476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
#6 0x00007df6db6287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
#7 0x00007df6db62871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
#8 0x00007df6db639e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#9 0x000000000745474d clang::ASTContext::getTypeInfoImpl(clang::Type const*) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x745474d)
#10 0x000000000743d907 clang::ASTContext::getTypeInfo(clang::Type const*) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x743d907)
#11 0x000000000745566b clang::ASTContext::getTypeInfoInChars(clang::Type const*) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x745566b)
#12 0x00000000074560fb clang::ASTContext::getTypeSizeInChars(clang::QualType) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x74560fb)
#13 0x000000000770d408 HandleSizeof((anonymous namespace)::EvalInfo&, clang::SourceLocation, clang::QualType, clang::CharUnits&, SizeOfType) ExprConstant.cpp:0:0
#14 0x000000000771e4da (anonymous namespace)::IntExprEvaluator::VisitUnaryExprOrTypeTraitExpr(clang::UnaryExprOrTypeTraitExpr const*) ExprConstant.cpp:0:0
#15 0x000000000774c084 clang::StmtVisitorBase<llvm::make_const_ptr, (anonymous namespace)::IntExprEvaluator, bool>::Visit(clang::Stmt const*) ExprConstant.cpp:0:0
#16 0x000000000773a5c6 Evaluate(clang::APValue&, (anonymous namespace)::EvalInfo&, clang::Expr const*) ExprConstant.cpp:0:0
#17 0x0000000007756e56 EvaluateInPlace(clang::APValue&, (anonymous namespace)::EvalInfo&, (anonymous namespace)::LValue const&, clang::Expr const*, bool) ExprConstant.cpp:0:0
#18 0x00000000077989e6 clang::Expr::EvaluateAsInitializer(clang::APValue&, clang::ASTContext const&, clang::VarDecl const*, llvm::SmallVectorImpl<std::pair<clang::SourceLocation, clang::PartialDiagnostic>>&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x77989e6)
#19 0x0000000007609332 clang::VarDecl::evaluateValueImpl(llvm::SmallVectorImpl<std::pair<clang::SourceLocation, clang::PartialDiagnostic>>&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x7609332)
#20 0x00000000076096b1 clang::VarDecl::checkForConstantInitialization(llvm::SmallVectorImpl<std::pair<clang::SourceLocation, clang::PartialDiagnostic>>&) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x76096b1)
#21 0x000000000695ef9e clang::Sema::CheckCompleteVariableDeclaration(clang::VarDecl*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x695ef9e)
#22 0x00000000069658ce clang::Sema::AddInitializerToDecl(clang::Decl*, clang::Expr*, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x69658ce)
#23 0x00000000065fea0a clang::Parser::ParseDeclarationAfterDeclaratorAndAttributes(clang::Declarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::ForRangeInit*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x65fea0a)
#24 0x000000000660daa9 clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::ParsedAttributes&, clang::Parser::ParsedTemplateInfo&, clang::SourceLocation*, clang::Parser::ForRangeInit*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x660daa9)
#25 0x00000000065cd87e clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x65cd87e)
#26 0x00000000065ce039 clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x65ce039)
#27 0x00000000065d57b3 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x65d57b3)
#28 0x00000000065d667d clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x65d667d)
#29 0x00000000065c8bba clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x65c8bba)
#30 0x00000000045e05c8 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x45e05c8)
#31 0x0000000004899a19 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4899a19)
#32 0x000000000481c41e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x481c41e)
#33 0x000000000498625e clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x498625e)
#34 0x0000000000ce1caf cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xce1caf)
#35 0x0000000000cd974a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#36 0x0000000004624a39 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
#37 0x0000000003ba2474 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3ba2474)
#38 0x000000000462502f 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
#39 0x00000000045ea33d clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x45ea33d)
#40 0x00000000045eb42d 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+++0x45eb42d)
#41 0x00000000045f29a5 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x45f29a5)
#42 0x0000000000cdeaf3 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xcdeaf3)
#43 0x0000000000bac394 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xbac394)
#44 0x00007df6db629d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#45 0x00007df6db629e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#46 0x0000000000cd91f5 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xcd91f5) Compiler Explorer: https://compiler-explorer.com/z/cGf99cMx5 |
https://compiler-explorer.com/z/vfvqd941z
minimized reproducer:
The text was updated successfully, but these errors were encountered: