<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 - Regression: FE crashes in clang::TypeVisitor::Visit()"
   href="https://bugs.llvm.org/show_bug.cgi?id=45102">45102</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Regression: FE crashes in clang::TypeVisitor::Visit()
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>10.0
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>Other
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>release blocker
          </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>xingxue@ca.ibm.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>Created <span class=""><a href="attachment.cgi?id=23202" name="attach_23202" title="diagnostic msg: t-797489.sh">attachment 23202</a> <a href="attachment.cgi?id=23202&action=edit" title="diagnostic msg: t-797489.sh">[details]</a></span>
diagnostic msg: t-797489.sh

The front-end crashes in clang::TypeVisitor::Visit() when compiling the
following small test case with CLANG 10.0.0 RC2 and the trunk.  CLANG 9.0.0 and
CLANG 9.0.1 compile it successfully so it is a regression.

The crash occurs with
<a href="https://github.com/llvm/llvm-project/commit/9dcfc7cd64abb301124cafaa95661b76a1fc5032">https://github.com/llvm/llvm-project/commit/9dcfc7cd64abb301124cafaa95661b76a1fc5032</a>
(the first buildable state after the culprit commit) and passes with a revert
of
<a href="https://github.com/llvm/llvm-project/commit/84959ae47f447fca9d56a9c61e8c46e993d0387a">https://github.com/llvm/llvm-project/commit/84959ae47f447fca9d56a9c61e8c46e993d0387a</a>
(which landed while the build was broken).

Test case:
$ cat t.cpp
template <typename T> using Id = T;

template <typename T>
void g() {
  extern Id<void (T)> f;
  f(0);
}

int main(void) { g<int>(); }
$

Compiling with 9.0.1 passes:
$ /home/xingxue/install-9.0.1/bin/clang++ -std=c++11 -x c++ -c t.cpp
$

Compiling with 10.0.0.rc2 crashes:
$ /home/xingxue/install-10.0.0.rc2/bin/clang++ -std=c++11 -x c++ -c t.cpp
Stack dump:
0.      Program arguments: /home/xingxue/install-10.0.0.rc2/bin/clang++
-std=c++11 -x c++ -c t.cpp
1.      <eof> parser at end of file
2.      t.cpp:4:6: instantiating function definition 'g<int>'
 #0 0x0000000012083c14 PrintStackTraceSignalHandler(void*)
(/home/xingxue/install-10.0.0.rc2/bin/clang+++0x12083c14)
 #1 0x0000000012080e98 llvm::sys::RunSignalHandlers()
(/home/xingxue/install-10.0.0.rc2/bin/clang+++0x12080e98)
 #2 0x00000000120824f0 llvm::sys::CleanupOnSignal(unsigned long)
(/home/xingxue/install-10.0.0.rc2/bin/clang+++0x120824f0)
 #3 0x0000000011ff8618 CrashRecoverySignalHandler(int)
(/home/xingxue/install-10.0.0.rc2/bin/clang+++0x11ff8618)
 #4 0x00007197e59b04d8 (linux-vdso64.so.1+0x4d8)
 #5 0x0000000013e9d3d0 clang::TypeVisitor<(anonymous
namespace)::GetContainedInventedTypeParmVisitor,
clang::TemplateTypeParmDecl*>::Visit(clang::Type const*)
(/home/xingxue/install-10.0.0.rc2/bin/clang+++0x13e9d3d0)
 #6 0x0000000013e929bc clang::TreeTransform<(anonymous
namespace)::TemplateInstantiator>::TransformFunctionTypeParams(clang::SourceLocation,
llvm::ArrayRef<clang::ParmVarDecl*>, clang::QualType const*,
clang::FunctionType::ExtParameterInfo const*,
llvm::SmallVectorImpl<clang::QualType>&,
llvm::SmallVectorImpl<clang::ParmVarDecl*>*,
clang::Sema::ExtParameterInfoBuilder&)
(/home/xingxue/install-10.0.0.rc2/bin/clang+++0x13e929bc)
 #7 0x0000000013e92600 clang::Sema::SubstParmTypes(clang::SourceLocation,
llvm::ArrayRef<clang::ParmVarDecl*>, clang::FunctionType::ExtParameterInfo
const*, clang::MultiLevelTemplateArgumentList const&,
llvm::SmallVectorImpl<clang::QualType>&,
llvm::SmallVectorImpl<clang::ParmVarDecl*>*,
clang::Sema::ExtParameterInfoBuilder&)
(/home/xingxue/install-10.0.0.rc2/bin/clang+++0x13e92600)
 #8 0x0000000013ece29c
clang::TemplateDeclInstantiator::SubstFunctionType(clang::FunctionDecl*,
llvm::SmallVectorImpl<clang::ParmVarDecl*>&)
(/home/xingxue/install-10.0.0.rc2/bin/clang+++0x13ece29c)
 #9 0x0000000013ecc2c4
clang::TemplateDeclInstantiator::VisitFunctionDecl(clang::FunctionDecl*,
clang::TemplateParameterList*, clang::TemplateDeclInstantiator::RewriteKind)
(/home/xingxue/install-10.0.0.rc2/bin/clang+++0x13ecc2c4)
#10 0x0000000013ed3840
clang::TemplateDeclInstantiator::VisitFunctionDecl(clang::FunctionDecl*)
(/home/xingxue/install-10.0.0.rc2/bin/clang+++0x13ed3840)
#11 0x0000000013e94fb8 clang::declvisitor::Base<std::add_pointer,
clang::TemplateDeclInstantiator, clang::Decl*>::Visit(clang::Decl*)
(/home/xingxue/install-10.0.0.rc2/bin/clang+++0x13e94fb8)
#12 0x0000000013eda88c void llvm::function_ref<void
()>::callback_fn<clang::Sema::SubstDecl(clang::Decl*, clang::DeclContext*,
clang::MultiLevelTemplateArgumentList const&)::$_0>(long)
(/home/xingxue/install-10.0.0.rc2/bin/clang+++0x13eda88c)
#13 0x00000000138200e8
clang::Sema::runWithSufficientStackSpace(clang::SourceLocation,
llvm::function_ref<void ()>)
(/home/xingxue/install-10.0.0.rc2/bin/clang+++0x138200e8)
#14 0x0000000013ed4898 clang::Sema::SubstDecl(clang::Decl*,
clang::DeclContext*, clang::MultiLevelTemplateArgumentList const&)
(/home/xingxue/install-10.0.0.rc2/bin/clang+++0x13ed4898)
#15 0x0000000013eb6208 clang::TreeTransform<(anonymous
namespace)::TemplateInstantiator>::TransformDeclStmt(clang::DeclStmt*)
(/home/xingxue/install-10.0.0.rc2/bin/clang+++0x13eb6208)
#16 0x0000000013eb0f30 clang::TreeTransform<(anonymous
namespace)::TemplateInstantiator>::TransformCompoundStmt(clang::CompoundStmt*,
bool) (/home/xingxue/install-10.0.0.rc2/bin/clang+++0x13eb0f30)
#17 0x0000000013e97720 clang::Sema::SubstStmt(clang::Stmt*,
clang::MultiLevelTemplateArgumentList const&)
(/home/xingxue/install-10.0.0.rc2/bin/clang+++0x13e97720)
#18 0x0000000013ed69c0
clang::Sema::InstantiateFunctionDefinition(clang::SourceLocation,
clang::FunctionDecl*, bool, bool, bool)
(/home/xingxue/install-10.0.0.rc2/bin/clang+++0x13ed69c0)
#19 0x0000000013ed8ecc clang::Sema::PerformPendingInstantiations(bool)
(/home/xingxue/install-10.0.0.rc2/bin/clang+++0x13ed8ecc)
#20 0x000000001382298c
clang::Sema::ActOnEndOfTranslationUnitFragment(clang::Sema::TUFragmentKind)
(/home/xingxue/install-10.0.0.rc2/bin/clang+++0x1382298c)
#21 0x000000001382311c clang::Sema::ActOnEndOfTranslationUnit()
(/home/xingxue/install-10.0.0.rc2/bin/clang+++0x1382311c)
#22 0x000000001372c2c0
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, bool)
(/home/xingxue/install-10.0.0.rc2/bin/clang+++0x1372c2c0)
#23 0x00000000137268a0 clang::ParseAST(clang::Sema&, bool, bool)
(/home/xingxue/install-10.0.0.rc2/bin/clang+++0x137268a0)
#24 0x0000000012808c1c clang::ASTFrontendAction::ExecuteAction()
(/home/xingxue/install-10.0.0.rc2/bin/clang+++0x12808c1c)
#25 0x0000000012e0527c clang::CodeGenAction::ExecuteAction()
(/home/xingxue/install-10.0.0.rc2/bin/clang+++0x12e0527c)
#26 0x00000000128083f4 clang::FrontendAction::Execute()
(/home/xingxue/install-10.0.0.rc2/bin/clang+++0x128083f4)
#27 0x00000000127a8a6c
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/home/xingxue/install-10.0.0.rc2/bin/clang+++0x127a8a6c)
#28 0x00000000128c969c
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/home/xingxue/install-10.0.0.rc2/bin/clang+++0x128c969c)
#29 0x00000000104d0870 cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/home/xingxue/install-10.0.0.rc2/bin/clang+++0x104d0870)
#30 0x00000000104cdf20 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&)
(/home/xingxue/install-10.0.0.rc2/bin/clang+++0x104cdf20)
#31 0x000000001267cb94 void llvm::function_ref<void
()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef>
<span class="quote">>, std::string*, bool*) const::$_1>(long)</span >
(/home/xingxue/install-10.0.0.rc2/bin/clang+++0x1267cb94)
#32 0x0000000011ff82a4
llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>)
(/home/xingxue/install-10.0.0.rc2/bin/clang+++0x11ff82a4)
#33 0x000000001267bc98
clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef>
<span class="quote">>, std::string*, bool*) const</span >
(/home/xingxue/install-10.0.0.rc2/bin/clang+++0x1267bc98)
#34 0x000000001264d834
clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&,
clang::driver::Command const*&) const
(/home/xingxue/install-10.0.0.rc2/bin/clang+++0x1264d834)
#35 0x000000001264dd68
clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&,
llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&) const
(/home/xingxue/install-10.0.0.rc2/bin/clang+++0x1264dd68)
#36 0x0000000012662dd0
clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&,
llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&)
(/home/xingxue/install-10.0.0.rc2/bin/clang+++0x12662dd0)
#37 0x00000000104cd1ec main
(/home/xingxue/install-10.0.0.rc2/bin/clang+++0x104cd1ec)
#38 0x00007197e526441c generic_start_main
/build/glibc-uvws04/glibc-2.27/csu/../csu/libc-start.c:310:0
#39 0x00007197e5264618 __libc_start_main
/build/glibc-uvws04/glibc-2.27/csu/../sysdeps/unix/sysv/linux/powerpc/libc-start.c:116:0
clang-10: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 10.0.0
Target: powerpc64le-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/xingxue/install-10.0.0.rc2/bin
clang-10: note: diagnostic msg: 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.
clang-10: note: diagnostic msg:
********************

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

********************
$</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>