[LLVMbugs] [Bug 17953] New: crash on invalid in instantiation after out-of-line declaration

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Fri Nov 15 18:30:14 PST 2013


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

            Bug ID: 17953
           Summary: crash on invalid in instantiation after out-of-line
                    declaration
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: nlewycky at google.com
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Testcase in c++11:

template <template <typename> class Tmpl>
struct TemplateSel {
  struct Bind {
    typedef Tmpl<int> type;
  };
};
template <class TestSel>
struct TypeParameterizedTest {
  static void Register() {
    typename TestSel::Bind::type TestClass;
  }
};
template <typename>
class Cls {
  virtual void TestBody();
};
auto test_ = TypeParameterizedTest<TemplateSel<Cls>>::Register;
template <typename T>
void Cls<T>::TestBody() {
  class InnerCls {
    void TestBody();
  };
  void InnerCls : TestBody();
}

Reproduce with clang -std=gnu++11 -fsyntax-only.
c.cc:23:17: error: unexpected ':' in nested name specifier; did you mean '::'?
  void InnerCls : TestBody();
                ^
                ::
c.cc:23:19: error: out-of-line declaration of a member must be a definition
      [-Wout-of-line-declaration]
  void InnerCls : TestBody();
       ~~~~~~~~~~ ^
clang: /usr/local/google/home/nlewycky/llvm/include/llvm/Support/Casting.h:239:
typename llvm::cast_retty<X, Y*>::ret_type llvm::cast(Y*) [with X =
clang::CXXRecordDecl, Y = clang::DeclContext, typename llvm::cast_retty<X,
Y*>::ret_type = clang::CXXRecordDecl*]: Assertion `isa<X>(Val) && "cast<Ty>()
argument of incompatible type!"' failed.
0  clang           0x000000000335f2af llvm::sys::PrintStackTrace(_IO_FILE*) +
38

1  clang           0x000000000335f536
2  clang           0x000000000335ef7a
3  libpthread.so.0 0x00007fa4677f7cb0
4  libc.so.6       0x00007fa466821425 gsignal + 53
5  libc.so.6       0x00007fa466824b8b abort + 379
6  libc.so.6       0x00007fa46681a0ee
7  libc.so.6       0x00007fa46681a192
8  clang           0x0000000000f00c25 llvm::cast_retty<clang::CXXRecordDecl,
clang::DeclContext*>::ret_type llvm::cast<clang::CXXRecordDecl,
clang::DeclContext>(clang::DeclContext*) + 62
9  clang           0x000000000167600e
clang::TemplateDeclInstantiator::SubstFunctionType(clang::FunctionDecl*,
llvm::SmallVectorImpl<clang::ParmVarDecl*>&) + 242
10 clang           0x000000000167100e
clang::TemplateDeclInstantiator::VisitCXXMethodDecl(clang::CXXMethodDecl*,
clang::TemplateParameterList*, bool) + 746
11 clang           0x00000000016748cc
clang::TemplateDeclInstantiator::VisitCXXMethodDecl(clang::CXXMethodDecl*) + 42
12 clang           0x0000000001663b51
13 clang           0x00000000016750a2 clang::Sema::SubstDecl(clang::Decl*,
clang::DeclContext*, clang::MultiLevelTemplateArgumentList const&) + 142
14 clang           0x0000000001632d62
15 clang           0x0000000001648038
16 clang           0x000000000163e30b
17 clang           0x0000000001659a6a
18 clang           0x0000000001647f7a
19 clang           0x000000000163e2b5
20 clang           0x0000000001638cbe clang::Sema::SubstStmt(clang::Stmt*,
clang::MultiLevelTemplateArgumentList const&) + 134
21 clang           0x000000000167829f
clang::Sema::InstantiateFunctionDefinition(clang::SourceLocation,
clang::FunctionDecl*, bool, bool) + 2407
22 clang           0x000000000167c24d
clang::Sema::PerformPendingInstantiations(bool) + 599
23 clang           0x00000000016783f3
clang::Sema::InstantiateFunctionDefinition(clang::SourceLocation,
clang::FunctionDecl*, bool, bool) + 2747
24 clang           0x000000000167c24d
clang::Sema::PerformPendingInstantiations(bool) + 599
25 clang           0x000000000125e695 clang::Sema::ActOnEndOfTranslationUnit()
+ 613
26 clang           0x00000000011c3734
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&) + 308
27 clang           0x00000000011bfb6d clang::ParseAST(clang::Sema&, bool, bool)
+ 597
28 clang           0x0000000000d609ef clang::ASTFrontendAction::ExecuteAction()
+ 321
29 clang           0x0000000000d6052e clang::FrontendAction::Execute() + 200
30 clang           0x0000000000d31bf8
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 720
31 clang           0x0000000000d00526
clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 1018
32 clang           0x0000000000cf1358 cc1_main(char const**, char const**, char
const*, void*) + 717
33 clang           0x0000000000cfbbf6 main + 786
34 libc.so.6       0x00007fa46680c76d __libc_start_main + 237
35 clang           0x0000000000cf0a59
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 c.cc
-mrelocation-model static -mdisable-fp-elim -fmath-errno -masm-verbose
-mconstructor-aliases -munwind-tables -target-cpu x86-64 -target-linker-version
2.22 -resource-dir
/usr/local/google/home/nlewycky/llvm/Debug+Asserts/bin/../lib/clang/3.4
-internal-isystem /usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../include/c++/4.6
-internal-isystem
/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../include/c++/4.6/x86_64-linux-gnu
-internal-isystem
/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../include/c++/4.6/backward
-internal-isystem
/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../include/x86_64-linux-gnu/c++/4.6
-internal-isystem /usr/local/include -internal-isystem
/usr/local/google/home/nlewycky/llvm/Debug+Asserts/bin/../lib/clang/3.4/include
-internal-externc-isystem /usr/include/x86_64-linux-gnu
-internal-externc-isystem /include -internal-externc-isystem /usr/include
-std=gnu++11 -fdeprecated-macro -fdebug-compilation-dir
/usr/local/google/home/nlewycky -ferror-limit 19 -fmessage-length 80
-mstackrealign -fobjc-runtime=gcc -fcxx-exceptions -fexceptions
-fdiagnostics-show-option -fcolor-diagnostics -vectorize-slp -x c++ c.cc 
1.      <eof> parser at end of file
2.      c.cc:9:15: instantiating function definition 'Register'
3.      c.cc:15:16: instantiating function definition 'TestBody'
clang: error: unable to execute command: Aborted (core dumped)
clang: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 3.4 (trunk 194757) (llvm/trunk 188326:194757M)
Target: x86_64-unknown-linux-gnu
Thread model: posix

-- 
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/20131116/437ef09b/attachment.html>


More information about the llvm-bugs mailing list