[llvm-bugs] [Bug 28308] New: clang crashes on C++11 code with invalid unqualified name lookup: Assertion `Spec->getTemplateSpecializationKind() == TSK_ExplicitSpecialization' failed

via llvm-bugs llvm-bugs at lists.llvm.org
Sat Jun 25 22:45:10 PDT 2016


https://llvm.org/bugs/show_bug.cgi?id=28308

            Bug ID: 28308
           Summary: clang crashes on C++11 code with invalid unqualified
                    name lookup: Assertion
                    `Spec->getTemplateSpecializationKind() ==
                    TSK_ExplicitSpecialization' failed
           Product: clang
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++11
          Assignee: unassignedclangbugs at nondot.org
          Reporter: su at cs.ucdavis.edu
                CC: dgregor at apple.com, llvm-bugs at lists.llvm.org
    Classification: Unclassified

The current clang trunk crashes when compiling the following C++11 test case on
x86_64-linux-gnu in both 32-bit and 64-bit modes. 

This is a regression from 3.8.x. 


$ clang++ -v
clang version 3.9.0 (trunk 273780)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/clang-trunk/bin
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/4.9
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/4.9.3
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/5
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/5.3.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.4
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.4.7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.6
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.6.4
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.7.3
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8.5
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9.3
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.3.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6.1.1
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Candidate multilib: x32;@mx32
Selected multilib: .;@m64
$ 
$ clang++-3.8 -c -std=c++11 small.cpp
small.cpp:14:10: error: enumerator 'e' does not exist in instantiation of
'A<int>'
  return e;  // should be: return A < T >::E::e;
         ^
small.cpp:8:20: note: in instantiation of member function 'A<int>::h' requested
here
A < int >::E b = a.h ();
                   ^
small.cpp:3:8: note: enum 'A<int>::E' was explicitly specialized here
  enum E : T;
       ^
1 error generated.
$ 
$ clang++ -c -std=c++11 small.cpp
clang-3.9:
/tmp/llvm-builder/llvm-source-trunk/tools/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp:4868:
clang::NamedDecl* clang::Sema::FindInstantiatedDecl(clang::SourceLocation,
clang::NamedDecl*, const clang::MultiLevelTemplateArgumentList&): Assertion
`Spec->getTemplateSpecializationKind() == TSK_ExplicitSpecialization' failed.
#0 0x0000000001d2e515 llvm::sys::PrintStackTrace(llvm::raw_ostream&)
(/usr/local/clang-trunk/bin/clang-3.9+0x1d2e515)
#1 0x0000000001d2c3a6 llvm::sys::RunSignalHandlers()
(/usr/local/clang-trunk/bin/clang-3.9+0x1d2c3a6)
#2 0x0000000001d2c5c4 SignalHandler(int)
(/usr/local/clang-trunk/bin/clang-3.9+0x1d2c5c4)
#3 0x00007f1294de7340 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x10340)
#4 0x00007f1293bd8cc9 gsignal
/build/eglibc-3GlaMS/eglibc-2.19/signal/../nptl/sysdeps/unix/sysv/linux/raise.c:56:0
#5 0x00007f1293bdc0d8 abort
/build/eglibc-3GlaMS/eglibc-2.19/stdlib/abort.c:91:0
#6 0x00007f1293bd1b86 __assert_fail_base
/build/eglibc-3GlaMS/eglibc-2.19/assert/assert.c:92:0
#7 0x00007f1293bd1c32 (/lib/x86_64-linux-gnu/libc.so.6+0x2fc32)
#8 0x0000000002e50135 clang::Sema::FindInstantiatedDecl(clang::SourceLocation,
clang::NamedDecl*, clang::MultiLevelTemplateArgumentList const&)
(/usr/local/clang-trunk/bin/clang-3.9+0x2e50135)
#9 0x0000000002e0ffc1 (anonymous
namespace)::TemplateInstantiator::TransformDecl(clang::SourceLocation,
clang::Decl*) (/usr/local/clang-trunk/bin/clang-3.9+0x2e0ffc1)
#10 0x0000000002e3730d clang::TreeTransform<(anonymous
namespace)::TemplateInstantiator>::TransformDeclRefExpr(clang::DeclRefExpr*)
(/usr/local/clang-trunk/bin/clang-3.9+0x2e3730d)
#11 0x0000000002e1a665 clang::TreeTransform<(anonymous
namespace)::TemplateInstantiator>::TransformExpr(clang::Expr*)
(/usr/local/clang-trunk/bin/clang-3.9+0x2e1a665)
#12 0x0000000002e1bd78 clang::TreeTransform<(anonymous
namespace)::TemplateInstantiator>::TransformInitializer(clang::Expr*, bool)
(/usr/local/clang-trunk/bin/clang-3.9+0x2e1bd78)
#13 0x0000000002e1bfc1 clang::TreeTransform<(anonymous
namespace)::TemplateInstantiator>::TransformReturnStmt(clang::ReturnStmt*)
(/usr/local/clang-trunk/bin/clang-3.9+0x2e1bfc1)
#14 0x0000000002e2d055 clang::TreeTransform<(anonymous
namespace)::TemplateInstantiator>::TransformStmt(clang::Stmt*)
(/usr/local/clang-trunk/bin/clang-3.9+0x2e2d055)
#15 0x0000000002e2e0e4 clang::TreeTransform<(anonymous
namespace)::TemplateInstantiator>::TransformCompoundStmt(clang::CompoundStmt*,
bool) (/usr/local/clang-trunk/bin/clang-3.9+0x2e2e0e4)
#16 0x0000000002e2e21b clang::TreeTransform<(anonymous
namespace)::TemplateInstantiator>::TransformCompoundStmt(clang::CompoundStmt*)
(/usr/local/clang-trunk/bin/clang-3.9+0x2e2e21b)
#17 0x0000000002e2d403 clang::TreeTransform<(anonymous
namespace)::TemplateInstantiator>::TransformStmt(clang::Stmt*)
(/usr/local/clang-trunk/bin/clang-3.9+0x2e2d403)
#18 0x0000000002e31788 clang::Sema::SubstStmt(clang::Stmt*,
clang::MultiLevelTemplateArgumentList const&)
(/usr/local/clang-trunk/bin/clang-3.9+0x2e31788)
#19 0x0000000002e57f01
clang::Sema::InstantiateFunctionDefinition(clang::SourceLocation,
clang::FunctionDecl*, bool, bool, bool)
(/usr/local/clang-trunk/bin/clang-3.9+0x2e57f01)
#20 0x0000000002e566e7 clang::Sema::PerformPendingInstantiations(bool)
(/usr/local/clang-trunk/bin/clang-3.9+0x2e566e7)
#21 0x0000000002a151cc clang::Sema::ActOnEndOfTranslationUnit()
(/usr/local/clang-trunk/bin/clang-3.9+0x2a151cc)
#22 0x00000000028092e1
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&)
(/usr/local/clang-trunk/bin/clang-3.9+0x28092e1)
#23 0x000000000280085b clang::ParseAST(clang::Sema&, bool, bool)
(/usr/local/clang-trunk/bin/clang-3.9+0x280085b)
#24 0x000000000249dd2e clang::CodeGenAction::ExecuteAction()
(/usr/local/clang-trunk/bin/clang-3.9+0x249dd2e)
#25 0x00000000021aa94e clang::FrontendAction::Execute()
(/usr/local/clang-trunk/bin/clang-3.9+0x21aa94e)
#26 0x00000000021800f6
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/usr/local/clang-trunk/bin/clang-3.9+0x21800f6)
#27 0x0000000002238932
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/usr/local/clang-trunk/bin/clang-3.9+0x2238932)
#28 0x0000000000af7b28 cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/usr/local/clang-trunk/bin/clang-3.9+0xaf7b28)
#29 0x0000000000aab16c main (/usr/local/clang-trunk/bin/clang-3.9+0xaab16c)
#30 0x00007f1293bc3ec5 __libc_start_main
/build/eglibc-3GlaMS/eglibc-2.19/csu/libc-start.c:321:0
#31 0x0000000000af3b94 _start (/usr/local/clang-trunk/bin/clang-3.9+0xaf3b94)
Stack dump:
0.      Program arguments: /usr/local/clang-trunk/bin/clang-3.9 -cc1 -triple
x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free -main-file-name
small.cpp -mrelocation-model static -mthread-model posix -mdisable-fp-elim
-fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables
-fuse-init-array -target-cpu x86-64 -dwarf-column-info -debugger-tuning=gdb
-coverage-file /data2/small.cpp -resource-dir
/usr/local/clang-trunk/bin/../lib/clang/3.9.0 -internal-isystem
/usr/lib/gcc/x86_64-linux-gnu/4.9/../../../../include/c++/4.9 -internal-isystem
/usr/lib/gcc/x86_64-linux-gnu/4.9/../../../../include/x86_64-linux-gnu/c++/4.9
-internal-isystem
/usr/lib/gcc/x86_64-linux-gnu/4.9/../../../../include/x86_64-linux-gnu/c++/4.9
-internal-isystem
/usr/lib/gcc/x86_64-linux-gnu/4.9/../../../../include/c++/4.9/backward
-internal-isystem /usr/local/include -internal-isystem
/usr/local/clang-trunk/bin/../lib/clang/3.9.0/include -internal-externc-isystem
/usr/include/x86_64-linux-gnu -internal-externc-isystem /include
-internal-externc-isystem /usr/include -std=c++11 -fdeprecated-macro
-fdebug-compilation-dir /data2 -ferror-limit 19 -fmessage-length 201
-fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fdiagnostics-show-option
-fcolor-diagnostics -o small.o -x c++ small.cpp 
1.      <eof> parser at end of file
2.      small.cpp:4:5: instantiating function definition 'A<int>::h'
clang-3.9: error: unable to execute command: Aborted (core dumped)
clang-3.9: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 3.9.0 (trunk 273780)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/clang-trunk/bin
clang-3.9: note: diagnostic msg: PLEASE submit a bug report to
http://llvm.org/bugs/ and include the crash backtrace, preprocessed source, and
associated run script.
clang-3.9: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-3.9: note: diagnostic msg: /tmp/small-3d30fe.cpp
clang-3.9: note: diagnostic msg: /tmp/small-3d30fe.sh
clang-3.9: note: diagnostic msg: 

********************
$ 

-----------------------------------------------------------


template < typename T > struct A
{
  enum E : T;
  E h ();
};

A < int > a;
A < int >::E b = a.h ();

template < typename T > enum A < T >::E : T { e };

template < typename T > typename A < T >::E A < T >::h ()
{
  return e;  // should be: return A < T >::E::e;
}

-- 
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/20160626/29f3e896/attachment.html>


More information about the llvm-bugs mailing list