<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - Crash on invalid: ResolveSingleFunctionTemplateSpecialization"
href="https://bugs.llvm.org/show_bug.cgi?id=49329">49329</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Crash on invalid: ResolveSingleFunctionTemplateSpecialization
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>C++
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>hokein@google.com
</td>
</tr>
<tr>
<th>CC</th>
<td>blitzrakete@gmail.com, dgregor@apple.com, erik.pilkington@gmail.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk
</td>
</tr></table>
<p>
<div>
<pre>Testcase:
template <typename T>
class C {
public:
template<int TT>
class Type {
};
};
template <typename T1>
class A {
public:
void foo() {
C<T1>::template Type<2>;
}
};
void test() {
A<float> a;
a.foo();
}
Crash stack trace:
clang: llvm-project/llvm/include/llvm/Support/Casting.h:269: typename
cast_retty<X, Y *>::ret_type llvm::cast(Y *) [X = clang::FunctionTemplateDecl,
Y = clang::NamedDecl]: Assertion `isa<X>(Val) && "cast<Ty>() argument of
incompatible type!"' failed.
PLEASE submit a bug report to <a href="https://bugs.llvm.org/">https://bugs.llvm.org/</a> and include the crash
backtrace, preprocessed source, and associated run script.
Stack dump:
0. Program arguments: ./bin/clang -cc1 -ast-dump /tmp/t1.cpp
1. <eof> parser at end of file
2. /tmp/t1.cpp:13:8: instantiating function definition 'A<float>::foo'
#0 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int)
llvm-project/llvm/lib/Support/Unix/Signals.inc:565:11
#1 PrintStackTraceSignalHandler(void*)
llvm-project/llvm/lib/Support/Unix/Signals.inc:632:1
#2 llvm::sys::RunSignalHandlers()
llvm-project/llvm/lib/Support/Signals.cpp:70:5
#3 SignalHandler(int) llvm-project/llvm/lib/Support/Unix/Signals.inc:407:1
#4 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14140)
#5 raise ./signal/../sysdeps/unix/sysv/linux/raise.c:51:1
#6 abort ./stdlib/abort.c:81:7
#7 get_sysdep_segment_value ./intl/loadmsgcat.c:509:8
#8 _nl_load_domain ./intl/loadmsgcat.c:970:34
#9 (/lib/x86_64-linux-gnu/libc.so.6+0x34662)
#10 llvm::cast_retty<clang::FunctionTemplateDecl, clang::NamedDecl*>::ret_type
llvm::cast<clang::FunctionTemplateDecl, clang::NamedDecl>(clang::NamedDecl*)
llvm-project/llvm/include/llvm/Support/Casting.h:270:10
#11
clang::Sema::ResolveSingleFunctionTemplateSpecialization(clang::OverloadExpr*,
bool, clang::DeclAccessPair*)
llvm-project/clang/lib/Sema/SemaOverload.cpp:12460:27
#12
clang::Sema::ResolveAndFixSingleFunctionTemplateSpecialization(clang::ActionResult<clang::Expr*,
true>&, bool, bool, clang::SourceRange, clang::QualType, unsigned int)
llvm-project/clang/lib/Sema/SemaOverload.cpp:12525:21
#13 clang::Sema::CheckPlaceholderExpr(clang::Expr*)
llvm-project/clang/lib/Sema/SemaExpr.cpp:19272:9
#14 clang::Sema::ActOnFinishFullExpr(clang::Expr*, clang::SourceLocation, bool,
bool) llvm-project/clang/lib/Sema/SemaExprCXX.cpp:8388:16
#15 clang::Sema::ActOnExprStmt(clang::ActionResult<clang::Expr*, true>, bool)
llvm-project/clang/lib/Sema/SemaStmt.cpp:49:8
#16 clang::TreeTransform<(anonymous
namespace)::TemplateInstantiator>::TransformStmt(clang::Stmt*,
clang::TreeTransform<(anonymous
namespace)::TemplateInstantiator>::StmtDiscardKind)
llvm-project/clang/lib/Sema/TreeTransform.h:3687:24
#17 clang::TreeTransform<(anonymous
namespace)::TemplateInstantiator>::TransformCompoundStmt(clang::CompoundStmt*,
bool) llvm-project/clang/lib/Sema/TreeTransform.h:7109:38
#18 clang::TreeTransform<(anonymous
namespace)::TemplateInstantiator>::TransformCompoundStmt(clang::CompoundStmt*)
llvm-project/clang/lib/Sema/TreeTransform.h:7095:23
#19 clang::TreeTransform<(anonymous
namespace)::TemplateInstantiator>::TransformStmt(clang::Stmt*,
clang::TreeTransform<(anonymous
namespace)::TemplateInstantiator>::StmtDiscardKind)
llvm-project/build-debug/tools/clang/include/clang/AST/StmtNodes.inc:73:1
#20 clang::Sema::SubstStmt(clang::Stmt*, clang::MultiLevelTemplateArgumentList
const&) llvm-project/clang/lib/Sema/SemaTemplateInstantiate.cpp:3460:23
#21 clang::Sema::InstantiateFunctionDefinition(clang::SourceLocation,
clang::FunctionDecl*, bool, bool, bool)
llvm-project/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp:4892:14
#22 clang::Sema::PerformPendingInstantiations(bool)
llvm-project/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp:6139:13
#23 clang::Sema::ActOnEndOfTranslationUnitFragment(clang::Sema::TUFragmentKind)
llvm-project/clang/lib/Sema/Sema.cpp:995:3
#24 clang::Sema::ActOnEndOfTranslationUnit()
llvm-project/clang/lib/Sema/Sema.cpp:1030:5
Looks like this is a regression, it is in trunk, but not reproducible in
clang-11.0.1.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>