Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

crash on template substitution of using decl #8077

Closed Quuxplusone closed 14 years ago

Quuxplusone commented 14 years ago
Bugzilla Link PR7645
Status RESOLVED DUPLICATE of bug 7641
Importance P normal
Reported by Nick Lewycky (nlewycky@google.com)
Reported on 2010-07-14 20:27:36 -0700
Last modified on 2010-07-15 18:17:17 -0700
Version trunk
Hardware PC Linux
CC dgregor@apple.com, llvm-bugs@lists.llvm.org
Fixed by commit(s)
Attachments
Blocks
Blocked by
See also
This small program demonstrates a crash in clang:

  template <class R> void NewPermanentCallback(R (*f)()) {}
  class Apple {};

  template <class T> bool Banana();
  using ::Banana;
  void foo() {
    NewPermanentCallback(Banana<Apple>);
  }

I think the code is valid, but haven't double-checked against the standard.
Here's the crash itself:

nlewycky@ducttape:~$ llvm/Debug+Asserts/bin/clang++ -fsyntax-only b2836285.cc
clang: /usr/local/google/home/nlewycky/llvm/include/llvm/Support/Casting.h:202:
typename llvm::cast_retty<To, From>::ret_type llvm::cast(const Y&) [with X =
clang::FunctionTemplateDecl, Y = clang::NamedDecl*]: Assertion `isa<X>(Val) &&
"cast<Ty>() argument of incompatible type!"' failed.
0  clang           0x000000000200b7e8
1  clang           0x000000000200b6ac
2  libpthread.so.0 0x00007ff08ecc78f0
3  libc.so.6       0x00007ff08dfb6a75 gsignal + 53
4  libc.so.6       0x00007ff08dfba5c0 abort + 384
5  libc.so.6       0x00007ff08dfaf941 __assert_fail + 241
6  clang           0x000000000110ca3a bool llvm::isa<clang::CXXRecordDecl,
clang::NamedDecl*>(clang::NamedDecl* const&) + 0
7  clang           0x000000000123a81b
clang::Sema::ResolveSingleFunctionTemplateSpecialization(clang::Expr*) + 357
8  clang           0x0000000001280239
9  clang           0x0000000001280851
clang::Sema::DeduceTemplateArguments(clang::FunctionTemplateDecl*,
clang::TemplateArgumentListInfo const*, clang::Expr**, unsigned int,
clang::FunctionDecl*&, clang::Sema::TemplateDeductionInfo&) + 699
10 clang           0x00000000012310a3
clang::Sema::AddTemplateOverloadCandidate(clang::FunctionTemplateDecl*,
clang::DeclAccessPair, clang::TemplateArgumentListInfo const*, clang::Expr**,
unsigned int, clang::OverloadCandidateSet&, bool) + 251
11 clang           0x000000000123aa73
12 clang           0x000000000123ace1
clang::Sema::AddOverloadedCallCandidates(clang::UnresolvedLookupExpr*,
clang::Expr**, unsigned int, clang::OverloadCandidateSet&, bool) + 581
13 clang           0x000000000123b594
clang::Sema::BuildOverloadedCallExpr(clang::Scope*, clang::Expr*,
clang::UnresolvedLookupExpr*, clang::SourceLocation, clang::Expr**, unsigned
int, clang::SourceLocation*, clang::SourceLocation) + 514
14 clang           0x00000000011b0386 clang::Sema::ActOnCallExpr(clang::Scope*,
clang::ASTOwningResult<&(clang::ActionBase::DeleteExpr(void*))>,
clang::SourceLocation,
clang::ASTMultiPtr<&(clang::ActionBase::DeleteExpr(void*))>,
clang::SourceLocation*, clang::SourceLocation) + 2956
15 clang           0x00000000015621d7
clang::Parser::ParsePostfixExpressionSuffix(clang::ASTOwningResult<&(clang::ActionBase::DeleteExpr(void*))>)
+ 2001
16 clang           0x000000000155fb98 clang::Parser::ParseCastExpression(bool,
bool, bool&, void*) + 2706
17 clang           0x000000000155f056 clang::Parser::ParseCastExpression(bool,
bool, void*) + 74
18 clang           0x000000000155dc9a
clang::Parser::ParseAssignmentExpression() + 258
19 clang           0x000000000155d643 clang::Parser::ParseExpression() + 37
20 clang           0x000000000153629d
clang::Parser::ParseStatementOrDeclaration(bool) + 1221
21 clang           0x0000000001537ebd
clang::Parser::ParseCompoundStatementBody(bool) + 255
22 clang           0x000000000153d27a
clang::Parser::ParseFunctionStatementBody(clang::OpaquePtr<0>) + 180
23 clang           0x0000000001543393
clang::Parser::ParseFunctionDefinition(clang::Parser::ParsingDeclarator&,
clang::Parser::ParsedTemplateInfo const&) + 1331
24 clang           0x0000000001548a06
clang::Parser::ParseDeclGroup(clang::Parser::ParsingDeclSpec&, unsigned int,
bool, clang::SourceLocation*) + 518
25 clang           0x0000000001542dd4
clang::Parser::ParseDeclarationOrFunctionDefinition(clang::Parser::ParsingDeclSpec&,
clang::AttributeList*, clang::AccessSpecifier) + 1152
26 clang           0x0000000001542e41
clang::Parser::ParseDeclarationOrFunctionDefinition(clang::AttributeList*,
clang::AccessSpecifier) + 95
27 clang           0x0000000001542734
clang::Parser::ParseExternalDeclaration(clang::CXX0XAttributeList) + 1728
28 clang           0x0000000001541fe5
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<1>&) + 279
29 clang           0x00000000010ff04c clang::ParseAST(clang::Preprocessor&,
clang::ASTConsumer*, clang::ASTContext&, bool, bool,
clang::CodeCompleteConsumer*) + 521
30 clang           0x0000000000ea1a5c clang::ASTFrontendAction::ExecuteAction()
+ 282
31 clang           0x0000000000ea16be clang::FrontendAction::Execute() + 320
32 clang           0x0000000000e8b149
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 751
33 clang           0x0000000000e4db1e cc1_main(char const**, char const**, char
const*, void*) + 1960
34 clang           0x0000000000e56904 main + 357
35 libc.so.6       0x00007ff08dfa1c4d __libc_start_main + 253
36 clang           0x0000000000e4c4b9
Stack dump:
0.      Program arguments:
/usr/local/google/home/nlewycky/llvm/Debug+Asserts/bin/clang -cc1 -triple
x86_64-unknown-linux-gnu -fsyntax-only -disable-free -main-file-name
b2836285.cc -mrelocation-model static -mdisable-fp-elim -mconstructor-aliases -
munwind-tables -target-cpu x86-64 -resource-dir
/usr/local/google/home/nlewycky/llvm/Debug+Asserts/lib/clang/2.8 -ferror-limit
19 -fmessage-length 80 -fexceptions -fgnu-runtime -fdiagnostics-show-option -
fcolor-diagnostics -x c++ b2836285.cc
1.      b2836285.cc:7:37: current parser token ')'
2.      b2836285.cc:6:12: parsing function body 'foo'
3.      b2836285.cc:6:12: in compound statement ('{}')
clang: error: clang frontend command failed due to signal 6 (use -v to see
invocation)
Quuxplusone commented 14 years ago

Ah, I just fixed this recently.

_This bug has been marked as a duplicate of bug 7641_