[llvm-bugs] [Bug 41800] New: Crash on missing 'get' with structured binding
via llvm-bugs
llvm-bugs at lists.llvm.org
Wed May 8 09:01:15 PDT 2019
https://bugs.llvm.org/show_bug.cgi?id=41800
Bug ID: 41800
Summary: Crash on missing 'get' with structured binding
Product: clang
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: C++'17
Assignee: unassignedclangbugs at nondot.org
Reporter: dblaikie at gmail.com
CC: blitzrakete at gmail.com, erik.pilkington at gmail.com,
llvm-bugs at lists.llvm.org, richard-llvm at metafoo.co.uk
This might also be a crash-on-valid (or at least crash-on-VS standard library
(may or may not be valid)).
creduce got me this:
struct d {
int x, y;
};
// template<size_t> int get(d);
namespace std {
template <size_t, class>
struct tuple_element {
using type = int;
};
template <class>
struct tuple_size;
template<>
struct tuple_size<d> {
static constexpr size_t value = 2;
};
}
d j();
template <int>
struct i {
static void k() {
auto [x, y] = j();
}
};
void fn1() {
i <8>
::k();
}
Crashes:
clang::VarDecl::checkInitIsICE() const tools/clang/lib/AST/Decl.cpp:0:3
checkTupleLikeDecomposition(clang::Sema&, llvm::ArrayRef<clang::BindingDecl*>,
clang::VarDecl*, clang::QualType, llvm::APSInt const&)
tools/clang/lib/Sema/SemaDeclCXX.cpp:1210:12
clang::Sema::CheckCompleteDecompositionDeclaration(clang::DecompositionDecl*)
tools/clang/lib/Sema/SemaDeclCXX.cpp:1432:9
clang::Sema::CheckCompleteVariableDeclaration(clang::VarDecl*)
tools/clang/lib/Sema/SemaDecl.cpp:11933:19
clang::Sema::AddInitializerToDecl(clang::Decl*, clang::Expr*, bool)
tools/clang/lib/Sema/SemaDecl.cpp:11451:1
clang::Parser::ParseDeclarationAfterDeclaratorAndAttributes(clang::Declarator&,
clang::Parser::ParsedTemplateInfo const&, clang::Parser::ForRangeInit*)
tools/clang/lib/Parse/ParseDecl.cpp:2325:5
clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&,
clang::DeclaratorContext, clang::SourceLocation*, clang::Parser::ForRangeInit*)
tools/clang/lib/Parse/ParseDecl.cpp:2059:9
clang::Parser::ParseSimpleDeclaration(clang::DeclaratorContext,
clang::SourceLocation&, clang::Parser::ParsedAttributesWithRange&, bool,
clang::Parser::ForRangeInit*) tools/clang/lib/Parse/ParseDecl.cpp:1784:10
clang::Parser::ParseDeclaration(clang::DeclaratorContext,
clang::SourceLocation&, clang::Parser::ParsedAttributesWithRange&)
tools/clang/lib/Parse/ParseDecl.cpp:1724:12
clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*,
32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*,
clang::Parser::ParsedAttributesWithRange&)
tools/clang/lib/Parse/ParseStmt.cpp:213:29
clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*,
32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*)
tools/clang/lib/Parse/ParseStmt.cpp:106:20
clang::Parser::ParseCompoundStatementBody(bool)
tools/clang/lib/Parse/ParseStmt.cpp:1057:11
clang::Parser::ParseFunctionStatementBody(clang::Decl*,
clang::Parser::ParseScope&) tools/clang/lib/Parse/ParseStmt.cpp:2070:21
clang::Parser::ParseLateTemplatedFuncDef(clang::LateParsedTemplate&)
tools/clang/lib/Parse/ParseTemplate.cpp:1462:7
clang::Parser::LateTemplateParserCallback(void*, clang::LateParsedTemplate&)
tools/clang/lib/Parse/ParseTemplate.cpp:1372:1
clang::Sema::InstantiateFunctionDefinition(clang::SourceLocation,
clang::FunctionDecl*, bool, bool, bool)
tools/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp:4146:15
clang::Sema::PerformPendingInstantiations(bool)
tools/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp:5485:13
clang::Sema::ActOnEndOfTranslationUnitFragment(clang::Sema::TUFragmentKind)
tools/clang/lib/Sema/Sema.cpp:908:3
clang::Sema::ActOnEndOfTranslationUnit() tools/clang/lib/Sema/Sema.cpp:932:5
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, bool)
tools/clang/lib/Parse/Parser.cpp:650:5
clang::ParseAST(clang::Sema&, bool, bool)
tools/clang/lib/Parse/ParseAST.cpp:158:16
clang::ASTFrontendAction::ExecuteAction()
tools/clang/lib/Frontend/FrontendAction.cpp:1037:1
clang::CodeGenAction::ExecuteAction()
tools/clang/lib/CodeGen/CodeGenAction.cpp:1057:1
clang::FrontendAction::Execute()
tools/clang/lib/Frontend/FrontendAction.cpp:938:7
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
tools/clang/lib/Frontend/CompilerInstance.cpp:945:7
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
tools/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:273:8
cc1_main(llvm::ArrayRef<char const*>, char const*, void*)
tools/clang/tools/driver/cc1_main.cpp:225:13
ExecuteCC1Tool(llvm::ArrayRef<char const*>, llvm::StringRef)
tools/clang/tools/driver/driver.cpp:309:5
main tools/clang/tools/driver/driver.cpp:381:5
It's possible that the original example (
https://gist.github.com/degski/3949d4bc2b723c659fae29cb4eabc47e ) crashes on
/valid/, but I can't tell for sure that VS stdlib's 'get' for std::pair is
valid - fixing the crash on invalid might reveal a better error message for the
std::pair situation. And it'd be pretty unfortunate if the VS standard library
had invalid code - might be worth/necessary to workaround it? Not sure.
But it's certainly related to structured bindings in the original - turning off
the two uses of structured bindings (both over std::pair) removes the crash.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20190508/818c47d1/attachment.html>
More information about the llvm-bugs
mailing list