[LLVMbugs] [Bug 12933] New: Nested template causes Clang assertion failure

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu May 24 01:58:59 PDT 2012


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

             Bug #: 12933
           Summary: Nested template causes Clang assertion failure
           Product: clang
           Version: unspecified
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: dmikurube at chromium.org
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified


Clang fails in assertion with the following simple C++ code.

template<typename S>
template<typename T>
void function(S a, T b) {;}
int main() {
  function(0, 1);
  return 0;
}


nested_template.cpp:1:1: error: extraneous template parameter list in template
specialization or out-of-line template definition
template<typename S>
^~~~~~~~~~~~~~~~~~~~
clang: .../llvm/tools/clang/lib/Sema/SemaTemplateDeduction.cpp:1002:
Sema::TemplateDeductionResult DeduceTemplateArgumentsByTypeMatch(clang::Sema &,
clang::TemplateParameterList *, clang::QualType, clang::QualType,
clang::sema::TemplateDeductionInfo &,
SmallVectorImpl<clang::DeducedTemplateArgument> &, unsigned int, bool,
SmallVectorImpl<RefParamPartialOrderingComparison> *): Assertion
`TemplateTypeParm->getDepth() == 0 && "Can't deduce with depth > 0"' failed.
0  clang     0x0000000001b3619f
1  clang     0x0000000001b366b4
2  libc.so.6 0x00007f3caa774af0
3  libc.so.6 0x00007f3caa774a75 gsignal + 53
4  libc.so.6 0x00007f3caa7785c0 abort + 384
5  libc.so.6 0x00007f3caa76d941 __assert_fail + 241
6  clang     0x0000000000b60ea7
7  clang     0x0000000000b5d3b5
clang::Sema::DeduceTemplateArguments(clang::FunctionTemplateDecl*,
clang::TemplateArgumentListInfo*, llvm::ArrayRef<clang::Expr*>,
clang::FunctionDecl*&, clang::sema::TemplateDeductionInfo&) + 1221
8  clang     0x0000000000ae0adc
clang::Sema::AddTemplateOverloadCandidate(clang::FunctionTemplateDecl*,
clang::DeclAccessPair, clang::TemplateArgumentListInfo*,
llvm::ArrayRef<clang::Expr*>, clang::OverloadCandidateSet&, bool) + 236
9  clang     0x0000000000aeb48c
10 clang     0x0000000000aeb289
clang::Sema::AddOverloadedCallCandidates(clang::UnresolvedLookupExpr*,
llvm::ArrayRef<clang::Expr*>, clang::OverloadCandidateSet&, bool) + 537
11 clang     0x0000000000aeb762
clang::Sema::BuildOverloadedCallExpr(clang::Scope*, clang::Expr*,
clang::UnresolvedLookupExpr*, clang::SourceLocation, clang::Expr**, unsigned
int, clang::SourceLocation, clang::Expr*, bool) + 674
12 clang     0x0000000000a11c3b clang::Sema::ActOnCallExpr(clang::Scope*,
clang::Expr*, clang::SourceLocation, clang::ASTMultiPtr<clang::Expr*>,
clang::SourceLocation, clang::Expr*, bool) + 1099
13 clang     0x00000000008bd663
clang::Parser::ParsePostfixExpressionSuffix(clang::ActionResult<clang::Expr*,
true>) + 2435
14 clang     0x00000000008bf5fb clang::Parser::ParseCastExpression(bool, bool,
bool&, clang::Parser::TypeCastState) + 6107
15 clang     0x00000000008bb704
clang::Parser::ParseAssignmentExpression(clang::Parser::TypeCastState) + 132
16 clang     0x00000000008bb669
clang::Parser::ParseExpression(clang::Parser::TypeCastState) + 9
17 clang     0x00000000008e24c8 clang::Parser::ParseExprStatement() + 56
18 clang     0x00000000008e202b
clang::Parser::ParseStatementOrDeclarationAfterAttributes(clang::ASTOwningVector<clang::Stmt*,
32u>&, bool, clang::SourceLocation*, clang::Parser::ParsedAttributesWithRange&)
+ 2187
19 clang     0x00000000008e16fb
clang::Parser::ParseStatementOrDeclaration(clang::ASTOwningVector<clang::Stmt*,
32u>&, bool, clang::SourceLocation*) + 155
20 clang     0x00000000008e7c6f clang::Parser::ParseCompoundStatementBody(bool)
+ 1391
21 clang     0x00000000008e955e
clang::Parser::ParseFunctionStatementBody(clang::Decl*,
clang::Parser::ParseScope&) + 174
22 clang     0x0000000000894d8b
clang::Parser::ParseFunctionDefinition(clang::Parser::ParsingDeclarator&,
clang::Parser::ParsedTemplateInfo const&,
llvm::SmallVector<clang::Parser::LateParsedAttribute*, 2u>*) + 1819
23 clang     0x00000000008a09f1
clang::Parser::ParseDeclGroup(clang::Parser::ParsingDeclSpec&, unsigned int,
bool, clang::SourceLocation*, clang::Parser::ForRangeInit*) + 1473
24 clang     0x0000000000894134
clang::Parser::ParseDeclarationOrFunctionDefinition(clang::Parser::ParsingDeclSpec&,
clang::AccessSpecifier) + 516
25 clang     0x000000000089433f
clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&,
clang::AccessSpecifier) + 303
26 clang     0x000000000089379c
clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&,
clang::Parser::ParsingDeclSpec*) + 2748
27 clang     0x0000000000892c60
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&) + 304
28 clang     0x000000000088f6fb clang::ParseAST(clang::Sema&, bool, bool) + 283
29 clang     0x0000000000767ea8 clang::CodeGenAction::ExecuteAction() + 184
30 clang     0x000000000063988d
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 973
31 clang     0x000000000062227b
clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 3307
32 clang     0x000000000061702b cc1_main(char const**, char const**, char
const*, void*) + 731
33 clang     0x000000000061e9aa main + 3466
34 libc.so.6 0x00007f3caa75fc4d __libc_start_main + 253
35 clang     0x0000000000616c89
Stack dump:
0.    Program arguments: .../clang -cc1 -triple x86_64-unknown-linux-gnu
-emit-obj -mrelax-all -disable-free -main-file-name nested_template.cpp
-mrelocation-model static -mdisable-fp-elim -fmath-errno -masm-verbose
-mconstructor-aliases -munwind-tables -target-cpu x86-64 -target-linker-version
2.20.1 -momit-leaf-frame-pointer -resource-dir .../bin/../lib/clang/3.2
-fmodule-cache-path /var/tmp/clang-module-cache -internal-isystem
/usr/lib/gcc/x86_64-linux-gnu/4.4/../../../../include/c++/4.4 -internal-isystem
/usr/lib/gcc/x86_64-linux-gnu/4.4/../../../../include/c++/4.4/x86_64-linux-gnu
-internal-isystem
/usr/lib/gcc/x86_64-linux-gnu/4.4/../../../../include/c++/4.4/backward
-internal-isystem /usr/local/include -internal-isystem
.../bin/../lib/clang/3.2/include -internal-externc-isystem
/usr/include/x86_64-linux-gnu -internal-externc-isystem /include
-internal-externc-isystem /usr/include -fdeprecated-macro
-fdebug-compilation-dir .../build -ferror-limit 19 -fmessage-length 132
-mstackrealign -fgnu-runtime -fobjc-runtime-has-arc -fobjc-runtime-has-weak
-fobjc-fragile-abi -fcxx-exceptions -fexceptions -fdiagnostics-show-option
-fcolor-diagnostics -o /tmp/nested_template-EXCBDE.o -x c++ nested_template.cpp 
1.    nested_template.cpp:5:16: current parser token ')'
2.    nested_template.cpp:4:12: parsing function body 'main'
3.    nested_template.cpp:4:12: in compound statement ('{}')
clang: error: unable to execute command: Aborted (core dumped)
clang: error: clang frontend command failed due to signal (use -v to see
invocation)
clang: note: diagnostic msg: Please submit a bug report to
http://llvm.org/bugs/ and include command line arguments and all diagnostic
information.
clang: note: diagnostic msg: Preprocessed source(s) and associated run
script(s) are located at:
clang: note: diagnostic msg: /tmp/nested_template-r7JsGN.ii
clang: note: diagnostic msg: /tmp/nested_template-r7JsGN.sh

-- 
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