[LLVMbugs] [Bug 20731] New: Assertion failure when taking the size of ill-formed lambda

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Fri Aug 22 00:06:04 PDT 2014


http://llvm.org/bugs/show_bug.cgi?id=20731

            Bug ID: 20731
           Summary: Assertion failure when taking the size of ill-formed
                    lambda
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: rtrieu at google.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Code:
template <class L, int X = sizeof(L)>
void Job(L l);

template <typename... Args>
void Logger(Args&&... args) {
  auto len = Invalid_Function((args)...);
  Job([len]() {});
} 

void GetMethod() {
  Logger();
}

Clang is attempting to calculate the sizeof(L) on line 2, reaches the undeduced
auto type of len, and asserts.

Commandline:
clang s1.cpp -std=c++11

Assertion:
tools/clang/lib/AST/ASTContext.cpp:1694: 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.

Output:
s1.cpp:6:14: error: use of undeclared identifier 'Invalid_Function'
  auto len = Invalid_Function((args)...);
             ^
s1.cpp:11:3: note: in instantiation of function template specialization
'Logger<>' requested here
  Logger();
  ^
0  clang           0x00000000011a94e5 llvm::sys::PrintStackTrace(_IO_FILE*) +
37
1  clang           0x00000000011a9933
2  libpthread.so.0 0x00007f5c57f06cb0
3  clang           0x00000000020f079f
clang::ASTContext::getTypeInfoImpl(clang::Type const*) const + 1231
4  clang           0x00000000020f019b
clang::ASTContext::getTypeInfo(clang::Type const*) const + 187
5  clang           0x00000000020f0074
clang::ASTContext::getTypeInfoInChars(clang::Type const*) const + 132
6  clang           0x000000000222cda1
7  clang           0x0000000002227f0b
clang::ASTContext::getASTRecordLayout(clang::RecordDecl const*) const + 1099
8  clang           0x00000000020f0921
clang::ASTContext::getTypeInfoImpl(clang::Type const*) const + 1617
9  clang           0x00000000020f019b
clang::ASTContext::getTypeInfo(clang::Type const*) const + 187
10 clang           0x00000000020f0776
clang::ASTContext::getTypeInfoImpl(clang::Type const*) const + 1190
11 clang           0x00000000020f019b
clang::ASTContext::getTypeInfo(clang::Type const*) const + 187
12 clang           0x00000000020f0074
clang::ASTContext::getTypeInfoInChars(clang::Type const*) const + 132
13 clang           0x00000000021caa95
14 clang           0x00000000021c2082
15 clang           0x00000000021be60d
16 clang           0x00000000021c19b9
clang::Expr::isCXX11ConstantExpr(clang::ASTContext const&, clang::APValue*,
clang::SourceLocation*) const + 377
17 clang           0x00000000021c06da
18 clang           0x00000000021c17e1
clang::Expr::isIntegerConstantExpr(llvm::APSInt&, clang::ASTContext const&,
clang::SourceLocation*, bool) const + 49
19 clang           0x0000000001da6868
clang::StandardConversionSequence::getNarrowingKind(clang::ASTContext&,
clang::Expr const*, clang::APValue&, clang::QualType&) const + 824
20 clang           0x0000000001db2267
clang::Sema::CheckConvertedConstantExpression(clang::Expr*, clang::QualType,
llvm::APSInt&, clang::Sema::CCEKind) + 1095
21 clang           0x0000000001e05822
clang::Sema::CheckTemplateArgument(clang::NonTypeTemplateParmDecl*,
clang::QualType, clang::Expr*, clang::TemplateArgument&,
clang::Sema::CheckTemplateArgumentKind) + 466
22 clang           0x0000000001e16f7f
clang::Sema::CheckTemplateArgument(clang::NamedDecl*,
clang::TemplateArgumentLoc&, clang::NamedDecl*, clang::SourceLocation,
clang::SourceLocation, unsigned int,
llvm::SmallVectorImpl<clang::TemplateArgument>&,
clang::Sema::CheckTemplateArgumentKind) + 2271
23 clang           0x0000000001e515ec
clang::Sema::FinishTemplateArgumentDeduction(clang::FunctionTemplateDecl*,
llvm::SmallVectorImpl<clang::DeducedTemplateArgument>&, unsigned int,
clang::FunctionDecl*&, clang::sema::TemplateDeductionInfo&,
llvm::SmallVectorImpl<clang::Sema::OriginalCallArg> const*) + 1692
24 clang           0x0000000001e53451
clang::Sema::DeduceTemplateArguments(clang::FunctionTemplateDecl*,
clang::TemplateArgumentListInfo*, llvm::ArrayRef<clang::Expr*>,
clang::FunctionDecl*&, clang::sema::TemplateDeductionInfo&) + 2977
25 clang           0x0000000001db7055
clang::Sema::AddTemplateOverloadCandidate(clang::FunctionTemplateDecl*,
clang::DeclAccessPair, clang::TemplateArgumentListInfo*,
llvm::ArrayRef<clang::Expr*>, clang::OverloadCandidateSet&, bool) + 309
26 clang           0x0000000001dc45f2
clang::Sema::AddOverloadedCallCandidates(clang::UnresolvedLookupExpr*,
llvm::ArrayRef<clang::Expr*>, clang::OverloadCandidateSet&, bool) + 354
27 clang           0x0000000001dc4700
clang::Sema::buildOverloadedCallSet(clang::Scope*, clang::Expr*,
clang::UnresolvedLookupExpr*, llvm::MutableArrayRef<clang::Expr*>,
clang::SourceLocation, clang::OverloadCandidateSet*,
clang::ActionResult<clang::Expr*, true>*) + 144
28 clang           0x0000000001dc4abd
clang::Sema::BuildOverloadedCallExpr(clang::Scope*, clang::Expr*,
clang::UnresolvedLookupExpr*, clang::SourceLocation,
llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation, clang::Expr*, bool)
+ 509
29 clang           0x0000000001c9a3af clang::Sema::ActOnCallExpr(clang::Scope*,
clang::Expr*, clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>,
clang::SourceLocation, clang::Expr*, bool) + 1295
30 clang           0x0000000001e919f7
31 clang           0x0000000001e817a9
32 clang           0x0000000001e80f44
33 clang           0x0000000001e8fd81
34 clang           0x0000000001e80ef1 clang::Sema::SubstStmt(clang::Stmt*,
clang::MultiLevelTemplateArgumentList const&) + 65
35 clang           0x0000000001ea6ed2
clang::Sema::InstantiateFunctionDefinition(clang::SourceLocation,
clang::FunctionDecl*, bool, bool) + 3650
36 clang           0x0000000001ea7a7e
clang::Sema::PerformPendingInstantiations(bool) + 430
37 clang           0x0000000001b15b4d clang::Sema::ActOnEndOfTranslationUnit()
+ 525
38 clang           0x000000000198a338
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&) + 168
39 clang           0x00000000019861f6 clang::ParseAST(clang::Sema&, bool, bool)
+ 422
40 clang           0x0000000001313c39 clang::FrontendAction::Execute() + 57
41 clang           0x00000000012e7ee3
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 787
42 clang           0x000000000138012c
clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 2844
43 clang           0x00000000006c5963 cc1_main(llvm::ArrayRef<char const*>,
char const*, void*) + 675
44 clang           0x00000000006c3b54 main + 7732
45 libc.so.6       0x00007f5c5742f78d __libc_start_main + 237
46 clang           0x00000000006c1bf1
Stack dump:
0.    Program arguments: clang -cc1 s1.cpp -std=c++11 
1.    <eof> parser at end of file
2.    s1.cpp:5:6: instantiating function definition 'Logger'
Segmentation fault (core dumped)

-- 
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/20140822/5bedd5c2/attachment.html>


More information about the llvm-bugs mailing list