<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </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 --- - ICE on invalid C++ code that instantiates undefined template: Assertion `!SpecializedTemplate.is<SpecializedPartialSpecialization*>() && "Already set to a class template partial specialization!"' failed"
   href="https://llvm.org/bugs/show_bug.cgi?id=30558">30558</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>ICE on invalid C++ code that instantiates undefined template: Assertion `!SpecializedTemplate.is<SpecializedPartialSpecialization*>() && "Already set to a class template partial specialization!"' failed
          </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>normal
          </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>su@cs.ucdavis.edu
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>dgregor@apple.com, llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>This is a regression from 3.4.x, and affects 3.5.x and later. 


$ clang++ -v
clang version 4.0.0 (trunk 282567)
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++ -c small.cpp
small.cpp:5:16: error: implicit instantiation of undefined template 'A<char
[10]>'
A < char[10] > a1, a2;
               ^
small.cpp:2:36: note: template is declared here
template < class T, int N > struct A < T[N] >;
                                   ^
clang-4.0:
/tmp/llvm-builder/llvm-source-trunk/tools/clang/include/clang/AST/DeclTemplate.h:1734:
void
clang::ClassTemplateSpecializationDecl::setInstantiationOf(clang::ClassTemplatePartialSpecializationDecl*,
const clang::TemplateArgumentList*): Assertion
`!SpecializedTemplate.is<SpecializedPartialSpecialization*>() && "Already set
to a class template partial specialization!"' failed.
#0 0x0000000001e81095 llvm::sys::PrintStackTrace(llvm::raw_ostream&)
(/usr/local/clang-trunk/bin/clang-4.0+0x1e81095)
#1 0x0000000001e7f17e llvm::sys::RunSignalHandlers()
(/usr/local/clang-trunk/bin/clang-4.0+0x1e7f17e)
#2 0x0000000001e7f2e0 SignalHandler(int)
(/usr/local/clang-trunk/bin/clang-4.0+0x1e7f2e0)
#3 0x00007f966a56f340 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x10340)
#4 0x00007f9669360cc9 gsignal
/build/eglibc-3GlaMS/eglibc-2.19/signal/../nptl/sysdeps/unix/sysv/linux/raise.c:56:0
#5 0x00007f96693640d8 abort
/build/eglibc-3GlaMS/eglibc-2.19/stdlib/abort.c:91:0
#6 0x00007f9669359b86 __assert_fail_base
/build/eglibc-3GlaMS/eglibc-2.19/assert/assert.c:92:0
#7 0x00007f9669359c32 (/lib/x86_64-linux-gnu/libc.so.6+0x2fc32)
#8 0x000000000305ffb3
clang::Sema::InstantiateClassTemplateSpecialization(clang::SourceLocation,
clang::ClassTemplateSpecializationDecl*, clang::TemplateSpecializationKind,
bool) (/usr/local/clang-trunk/bin/clang-4.0+0x305ffb3)
#9 0x000000000309babf
clang::Sema::RequireCompleteTypeImpl(clang::SourceLocation, clang::QualType,
clang::Sema::TypeDiagnoser*) (/usr/local/clang-trunk/bin/clang-4.0+0x309babf)
#10 0x000000000309bd85 clang::Sema::RequireCompleteType(clang::SourceLocation,
clang::QualType, clang::Sema::TypeDiagnoser&)
(/usr/local/clang-trunk/bin/clang-4.0+0x309bd85)
#11 0x000000000309bf63 clang::Sema::RequireCompleteType(clang::SourceLocation,
clang::QualType, unsigned int) (/usr/local/clang-trunk/bin/clang-4.0+0x309bf63)
#12 0x0000000002cdf02f clang::Sema::ActOnUninitializedDecl(clang::Decl*, bool)
(/usr/local/clang-trunk/bin/clang-4.0+0x2cdf02f)
#13 0x0000000002a29256
clang::Parser::ParseDeclarationAfterDeclaratorAndAttributes(clang::Declarator&,
clang::Parser::ParsedTemplateInfo const&, clang::Parser::ForRangeInit*)
(/usr/local/clang-trunk/bin/clang-4.0+0x2a29256)
#14 0x0000000002a37ed7 clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&,
unsigned int, clang::SourceLocation*, clang::Parser::ForRangeInit*)
(/usr/local/clang-trunk/bin/clang-4.0+0x2a37ed7)
#15 0x0000000002a133a9
clang::Parser::ParseDeclOrFunctionDefInternal(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec&, clang::AccessSpecifier)
(/usr/local/clang-trunk/bin/clang-4.0+0x2a133a9)
#16 0x0000000002a13a61
clang::Parser::ParseDeclarationOrFunctionDefinition(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*, clang::AccessSpecifier) [clone .part.223]
(/usr/local/clang-trunk/bin/clang-4.0+0x2a13a61)
#17 0x0000000002a13a9f
clang::Parser::ParseDeclarationOrFunctionDefinition(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*, clang::AccessSpecifier)
(/usr/local/clang-trunk/bin/clang-4.0+0x2a13a9f)
#18 0x0000000002a18768
clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*) (/usr/local/clang-trunk/bin/clang-4.0+0x2a18768)
#19 0x0000000002a192b2
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&)
(/usr/local/clang-trunk/bin/clang-4.0+0x2a192b2)
#20 0x0000000002a10683 clang::ParseAST(clang::Sema&, bool, bool)
(/usr/local/clang-trunk/bin/clang-4.0+0x2a10683)
#21 0x0000000002629a8e clang::CodeGenAction::ExecuteAction()
(/usr/local/clang-trunk/bin/clang-4.0+0x2629a8e)
#22 0x000000000232292e clang::FrontendAction::Execute()
(/usr/local/clang-trunk/bin/clang-4.0+0x232292e)
#23 0x00000000022f837e
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/usr/local/clang-trunk/bin/clang-4.0+0x22f837e)
#24 0x00000000023b18b2
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/usr/local/clang-trunk/bin/clang-4.0+0x23b18b2)
#25 0x0000000000b8ff10 cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/usr/local/clang-trunk/bin/clang-4.0+0xb8ff10)
#26 0x0000000000b38935 main (/usr/local/clang-trunk/bin/clang-4.0+0xb38935)
#27 0x00007f966934bec5 __libc_start_main
/build/eglibc-3GlaMS/eglibc-2.19/csu/libc-start.c:321:0
#28 0x0000000000b8c0be _start (/usr/local/clang-trunk/bin/clang-4.0+0xb8c0be)
Stack dump:
0.      Program arguments: /usr/local/clang-trunk/bin/clang-4.0 -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-notes-file /data2/small.gcno -resource-dir
/usr/local/clang-trunk/bin/../lib/clang/4.0.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/4.0.0/include -internal-externc-isystem
/usr/include/x86_64-linux-gnu -internal-externc-isystem /include
-internal-externc-isystem /usr/include -fdeprecated-macro
-fdebug-compilation-dir /data2 -ferror-limit 19 -fmessage-length 216
-fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fdiagnostics-show-option
-fcolor-diagnostics -o small.o -x c++ small.cpp
1.      small.cpp:5:22: current parser token ';'
clang-4.0: error: unable to execute command: Aborted (core dumped)
clang-4.0: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 4.0.0 (trunk 282567)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/clang-trunk/bin
clang-4.0: note: diagnostic msg: PLEASE submit a bug report to
<a href="http://llvm.org/bugs/">http://llvm.org/bugs/</a> and include the crash backtrace, preprocessed source, and
associated run script.
clang-4.0: note: diagnostic msg:
********************

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

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


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


template < class > struct A;
template < class T, int N > struct A < T[N] >;

// doesn't crash with: A < char[10] > a;
A < char[10] > a1, a2;</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>