[LLVMbugs] [Bug 10349] New: clang crashes when using template return type

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Jul 13 02:22:20 PDT 2011


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

           Summary: clang crashes when using template return type
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: MacOS X
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: llvm at niebuhrt.de
                CC: llvmbugs at cs.uiuc.edu


Created an attachment (id=6878)
 --> (http://llvm.org/bugs/attachment.cgi?id=6878)
file crashing clang

When compiling the attached code, clang crashes with a stack trace. The code is
probably wrong, but clang should produce an error.

clang++ -std=c++0x -stdlib=libc++ -U__STRICT_ANSI__ template_foo.cpp -o main

Assertion failed: (isa<LabelDecl>(D) && "declaration not instantiated in this
scope"), function findInstantiationOf, file SemaTemplateInstantiate.cpp, line
2324.
0  clang             0x00000001018f9b82 PrintStackTrace(void*) + 34
1  clang             0x00000001018fab03 SignalHandler(int) + 707
2  libSystem.B.dylib 0x00007fff877951ba _sigtramp + 26
3  libSystem.B.dylib 0x000001320000012a _sigtramp + 2022092682
4  clang             0x00000001018fa002 __assert_rtn + 66
5  clang             0x000000010066fe25
clang::LocalInstantiationScope::findInstantiationOf(clang::Decl const*) + 421
6  clang             0x00000001006ab908
clang::Sema::FindInstantiatedDecl(clang::SourceLocation, clang::NamedDecl*,
clang::MultiLevelTemplateArgumentList const&) + 104
7  clang             0x000000010069553b (anonymous
namespace)::TemplateInstantiator::TransformTemplateParmRefExpr(clang::DeclRefExpr*,
clang::NonTypeTemplateParmDecl*) + 603
8  clang             0x000000010067bf68 clang::TreeTransform<(anonymous
namespace)::TemplateInstantiator>::TransformExpr(clang::Expr*) + 4152
9  clang             0x00000001006840ea clang::TreeTransform<(anonymous
namespace)::TemplateInstantiator>::TransformTemplateArgument(clang::TemplateArgumentLoc
const&, clang::TemplateArgumentLoc&) + 1690
10 clang             0x00000001006891da bool clang::TreeTransform<(anonymous
namespace)::TemplateInstantiator>::TransformTemplateArguments<clang::(anonymous
namespace)::TemplateArgumentLocContainerIterator<clang::TemplateSpecializationTypeLoc>
>(clang::(anonymous
namespace)::TemplateArgumentLocContainerIterator<clang::TemplateSpecializationTypeLoc>,
clang::(anonymous
namespace)::TemplateArgumentLocContainerIterator<clang::TemplateSpecializationTypeLoc>,
clang::TemplateArgumentListInfo&) + 1850
11 clang             0x000000010068a49a clang::TreeTransform<(anonymous
namespace)::TemplateInstantiator>::TransformTemplateSpecializationType(clang::TypeLocBuilder&,
clang::TemplateSpecializationTypeLoc, clang::TemplateName) + 186
12 clang             0x000000010068d68d clang::TreeTransform<(anonymous
namespace)::TemplateInstantiator>::TransformTemplateSpecializationType(clang::TypeLocBuilder&,
clang::TemplateSpecializationTypeLoc) + 189
13 clang             0x00000001006805e9 clang::TreeTransform<(anonymous
namespace)::TemplateInstantiator>::TransformType(clang::TypeLocBuilder&,
clang::TypeLoc) + 889
14 clang             0x0000000100683991 clang::TreeTransform<(anonymous
namespace)::TemplateInstantiator>::TransformType(clang::TypeSourceInfo*) + 401
15 clang             0x0000000100692119 clang::TreeTransform<(anonymous
namespace)::TemplateInstantiator>::TransformType(clang::QualType) + 121
16 clang             0x0000000100694f94 clang::Sema::SubstType(clang::QualType,
clang::MultiLevelTemplateArgumentList const&, clang::SourceLocation,
clang::DeclarationName) + 68
17 clang             0x00000001006abca4
clang::Sema::FindInstantiatedDecl(clang::SourceLocation, clang::NamedDecl*,
clang::MultiLevelTemplateArgumentList const&) + 1028
18 clang             0x00000001006748ca (anonymous
namespace)::TemplateInstantiator::TransformDecl(clang::SourceLocation,
clang::Decl*) + 122
19 clang             0x000000010067a29f clang::TreeTransform<(anonymous
namespace)::TemplateInstantiator>::TransformInjectedClassNameType(clang::TypeLocBuilder&,
clang::InjectedClassNameTypeLoc) + 79
20 clang             0x0000000100680580 clang::TreeTransform<(anonymous
namespace)::TemplateInstantiator>::TransformType(clang::TypeLocBuilder&,
clang::TypeLoc) + 784
21 clang             0x0000000100683991 clang::TreeTransform<(anonymous
namespace)::TemplateInstantiator>::TransformType(clang::TypeSourceInfo*) + 401
22 clang             0x0000000100692119 clang::TreeTransform<(anonymous
namespace)::TemplateInstantiator>::TransformType(clang::QualType) + 121
23 clang             0x00000001006941be clang::TreeTransform<(anonymous
namespace)::TemplateInstantiator>::TransformDeclarationNameInfo(clang::DeclarationNameInfo
const&) + 622
24 clang             0x0000000100694f3d
clang::Sema::SubstDeclarationNameInfo(clang::DeclarationNameInfo const&,
clang::MultiLevelTemplateArgumentList const&) + 45
25 clang             0x00000001006ac85f
clang::TemplateDeclInstantiator::VisitCXXMethodDecl(clang::CXXMethodDecl*,
clang::TemplateParameterList*) + 767
26 clang             0x00000001006a4d92
clang::DeclVisitor<clang::TemplateDeclInstantiator,
clang::Decl*>::Visit(clang::Decl*) + 2290
27 clang             0x000000010069c6cc
clang::Sema::InstantiateClass(clang::SourceLocation, clang::CXXRecordDecl*,
clang::CXXRecordDecl*, clang::MultiLevelTemplateArgumentList const&,
clang::TemplateSpecializationKind, bool) + 1740
28 clang             0x000000010069de73
clang::Sema::InstantiateClassTemplateSpecialization(clang::SourceLocation,
clang::ClassTemplateSpecializationDecl*, clang::TemplateSpecializationKind,
bool) + 2371
29 clang             0x00000001006d0219
clang::Sema::RequireCompleteType(clang::SourceLocation, clang::QualType,
clang::PartialDiagnostic const&, std::pair<clang::SourceLocation,
clang::PartialDiagnostic>) + 937
30 clang             0x00000001004b7d91
clang::Sema::CheckCallReturnType(clang::QualType, clang::SourceLocation,
clang::CallExpr*, clang::FunctionDecl*) + 3137
31 clang             0x00000001005105b6
clang::Sema::BuildResolvedCallExpr(clang::Expr*, clang::NamedDecl*,
clang::SourceLocation, clang::Expr**, unsigned int, clang::SourceLocation,
clang::Expr*) + 230
32 clang             0x00000001005ad170
clang::Sema::BuildOverloadedCallExpr(clang::Scope*, clang::Expr*,
clang::UnresolvedLookupExpr*, clang::SourceLocation, clang::Expr**, unsigned
int, clang::SourceLocation, clang::Expr*) + 2000
33 clang             0x00000001005122b1
clang::Sema::ActOnCallExpr(clang::Scope*, clang::Expr*, clang::SourceLocation,
clang::ASTMultiPtr<clang::Expr*>, clang::SourceLocation, clang::Expr*) + 1489
34 clang             0x0000000100330977
clang::Parser::ParsePostfixExpressionSuffix(clang::ActionResult<clang::Expr*,
true>) + 1271
35 clang             0x000000010032adbb
clang::Parser::ParseCastExpression(bool, bool, bool&, bool) + 1195
36 clang             0x000000010032cf7a
clang::Parser::ParseAssignmentExpression() + 58
37 clang             0x000000010032ec71 clang::Parser::ParseExpression() + 17
38 clang             0x000000010031ba56
clang::Parser::ParseDecltypeSpecifier(clang::DeclSpec&) + 310
39 clang             0x000000010030e351
clang::Parser::ParseDeclarationSpecifiers(clang::DeclSpec&,
clang::Parser::ParsedTemplateInfo const&, clang::AccessSpecifier,
clang::Parser::DeclSpecContext) + 6641
40 clang             0x00000001003184c8
clang::Parser::ParseSimpleDeclaration(clang::ASTOwningVector<clang::Stmt*,
32u>&, unsigned int, clang::SourceLocation&, clang::ParsedAttributes&, bool,
clang::Parser::ForRangeInit*) + 600
41 clang             0x00000001003186d5
clang::Parser::ParseDeclaration(clang::ASTOwningVector<clang::Stmt*, 32u>&,
unsigned int, clang::SourceLocation&,
clang::Parser::ParsedAttributesWithRange&) + 133
42 clang             0x00000001003529c4
clang::Parser::ParseStatementOrDeclaration(clang::ASTOwningVector<clang::Stmt*,
32u>&, bool) + 3316
43 clang             0x0000000100353546
clang::Parser::ParseCompoundStatementBody(bool) + 1526
44 clang             0x0000000100353af9
clang::Parser::ParseFunctionStatementBody(clang::Decl*,
clang::Parser::ParseScope&) + 201
45 clang             0x000000010036c04a
clang::Parser::ParseFunctionDefinition(clang::Parser::ParsingDeclarator&,
clang::Parser::ParsedTemplateInfo const&) + 1130
46 clang             0x0000000100317cdc
clang::Parser::ParseDeclGroup(clang::Parser::ParsingDeclSpec&, unsigned int,
bool, clang::SourceLocation*, clang::Parser::ForRangeInit*) + 2844
47 clang             0x000000010036d2c8
clang::Parser::ParseDeclarationOrFunctionDefinition(clang::Parser::ParsingDeclSpec&,
clang::AccessSpecifier) + 168
48 clang             0x000000010036d74e
clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&,
clang::AccessSpecifier) + 478
49 clang             0x000000010036e343
clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&,
clang::Parser::ParsingDeclSpec*) + 2931
50 clang             0x000000010036ea4a
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&) + 554
51 clang             0x00000001002ff42b clang::ParseAST(clang::Sema&, bool) +
315
52 clang             0x00000001002cc1fc clang::CodeGenAction::ExecuteAction() +
60
53 clang             0x000000010002bec1
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 433
54 clang             0x000000010000adfb
clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 1547
55 clang             0x000000010000174c cc1_main(char const**, char const**,
char const*, void*) + 652
56 clang             0x0000000100009c1e main + 4526
57 clang             0x0000000100000b34 start + 52
Stack dump:
0.    Program arguments: /Users/niebuhr/projects/llvm/Release+Asserts/bin/clang
-cc1 -triple x86_64-apple-macosx10.6.8 -emit-obj -mrelax-all -disable-free
-main-file-name template_foo.cpp -pic-level 1 -mdisable-fp-elim -masm-verbose
-munwind-tables -target-cpu core2 -target-linker-version 123.2 -resource-dir
/Users/niebuhr/projects/llvm/Release+Asserts/bin/../lib/clang/3.0 -U
__STRICT_ANSI__ -stdlib=libc++ -std=c++0x -fdeprecated-macro -ferror-limit 19
-fmessage-length 151 -stack-protector 1 -fblocks -fcxx-exceptions -fexceptions
-fdiagnostics-show-option -fcolor-diagnostics -o
/var/folders/i1/i1WwOXILFa8QNqJQnuxxd++++TI/-Tmp-/cc-6U5LKY.o -x c++
template_foo.cpp 
1.    template_foo.cpp:31:41: current parser token ')'
2.    template_foo.cpp:29:13: parsing function body 'main'
3.    template_foo.cpp:29:13: in compound statement ('{}')
clang: error: unable to execute command: Illegal instruction

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list