<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 - c++ parser crash on invalid code"
   href="https://bugs.llvm.org/show_bug.cgi?id=43358">43358</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>c++ parser crash on invalid code
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>8.0
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </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++11
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>Emmanuel.Thome@inria.fr
          </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>Created <span class=""><a href="attachment.cgi?id=22526" name="attach_22526" title="complete source code">attachment 22526</a> <a href="attachment.cgi?id=22526&action=edit" title="complete source code">[details]</a></span>
complete source code

clang++ 8.0.1-3+b1 encounters a c++ crash on the attached code. I acknowledge
the fact that the code is invalid, but a parser crash should not occur.

Test source file, output, and reproducer attached.

template<bool happy>
struct pool {
    bool ok() const { return happy; }
    template<typename T> struct proxy {
        bool ok() { return T::f.ok(); }
    };
};
template<bool b> class obj {
    typedef pool<b> pool_t;
    static pool_t f;
public:
    typedef typename pool_t::template proxy<obj> proxy_t;
    template<> friend struct pool_t::proxy<obj>;  // ***parser crash***
};
extern template class obj<true>;
int main()
{
    obj<true>::proxy_t dummy;
    return dummy.ok();
}

Here's a small bit of the full stack trace

#4 0x00000000016e777e
clang::Sema::MatchTemplateParametersToScopeSpecifier(clang::SourceLocation,
clang::SourceLocation, clang::CXXScopeSpec const&,
clang::TemplateIdAnnotation*,
llvm::ArrayRef<clang::TemplateParameterList*>, bool, bool&, bool&)
(/usr/lib/llvm-8/bin/clang+0x16e777e)
#5 0x00000000016fb471
clang::Sema::ActOnClassTemplateSpecialization(clang::Scope*, unsigned
int, clang::Sema::TagUseKind, clang::SourceLocation, clang::SourceLocation,
clang::TemplateIdAnnotation&, clang::ParsedAttributesView const&,
llvm::MutableArrayRef<clang::TemplateParameterList*>,
clang::Sema::SkipBodyInfo*)
(/usr/lib/llvm-8/bin/clang+0x16fb471)</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>