<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 - Compiler crash when incorrectly define template variable with auto type"
   href="https://bugs.llvm.org/show_bug.cgi?id=52005">52005</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Compiler crash when incorrectly define template variable with auto type
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>12.0
          </td>
        </tr>

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

        <tr>
          <th>OS</th>
          <td>Windows NT
          </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++2b
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>fchelnokov@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>blitzrakete@gmail.com, erik.pilkington@gmail.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>The code as follows:
```
template <typename T>
auto p = p<T>;

auto x = p<int>;
```

crashes the compiler:
<a href="https://gcc.godbolt.org/z/a99aThzjj">https://gcc.godbolt.org/z/a99aThzjj</a>

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.
Stack dump:
0.      Program arguments: /opt/compiler-explorer/clang-trunk/bin/clang++ -g -o
/app/output.s -mllvm --x86-asm-syntax=intel -S
--gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics
-fno-crash-diagnostics -std=c++20 -Wall -Wextra -pedantic-errors <source>
1.      <eof> parser at end of file
2.      <source>:4:6: LLVM IR generation of declaration 'x'
3.      <source>:4:6: Generating code for declaration 'x'
 #0 0x0000556e3b7a626f PrintStackTraceSignalHandler(void*) Signals.cpp:0:0
 #1 0x0000556e3b7a4130 llvm::sys::CleanupOnSignal(unsigned long)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x35a4130)
 #2 0x0000556e3b6f4b38 CrashRecoverySignalHandler(int)
CrashRecoveryContext.cpp:0:0
 #3 0x00007fd94dedf3c0 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x153c0)
 #4 0x0000556e3ae87c04 llvm::ConstantFP::get(llvm::LLVMContext&, llvm::APFloat
const&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x2c87c04)
 #5 0x0000556e3ae91adf llvm::Constant::getNullValue(llvm::Type*)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x2c91adf)
 #6 0x0000556e3baeda1d
clang::CodeGen::CodeGenModule::EmitNullConstant(clang::QualType)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x38eda1d)
 #7 0x0000556e3bb8daa7
clang::CodeGen::CodeGenModule::EmitGlobalVarDefinition(clang::VarDecl const*,
bool) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x398daa7)
 #8 0x0000556e3bba88f5
clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl,
llvm::GlobalValue*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x39a88f5)
 #9 0x0000556e3bba913b
clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x39a913b)
#10 0x0000556e3bbaeded
clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) (.part.5289)
CodeGenModule.cpp:0:0
#11 0x0000556e3c7474c1 (anonymous
namespace)::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef)
ModuleBuilder.cpp:0:0
#12 0x0000556e3c73ab32
clang::BackendConsumer::HandleTopLevelDecl(clang::DeclGroupRef)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x453ab32)
#13 0x0000556e3d59f544 clang::ParseAST(clang::Sema&, bool, bool)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x539f544)
#14 0x0000556e3c7453b2 clang::CodeGenAction::ExecuteAction()
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x45453b2)
#15 0x0000556e3c0db771 clang::FrontendAction::Execute()
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x3edb771)
#16 0x0000556e3c078382
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x3e78382)
#17 0x0000556e3c1a8b93
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x3fa8b93)
#18 0x0000556e394d71ec cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x12d71ec)
#19 0x0000556e394d325d ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&)
driver.cpp:0:0
#20 0x0000556e3bf1cee5 void llvm::function_ref<void
()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef>
<span class="quote">>, std::__cxx11::basic_string<char, std::char_traits<char>,</span >
std::allocator<char> >*, bool*) const::'lambda'()>(long) Job.cpp:0:0
#21 0x0000556e3b6f5123
llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x34f5123)
#22 0x0000556e3bf1ef9e
clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef>
<span class="quote">>, std::__cxx11::basic_string<char, std::char_traits<char>,</span >
std::allocator<char> >*, bool*) const
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x3d1ef9e)
#23 0x0000556e3bef490a
clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&,
clang::driver::Command const*&) const
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x3cf490a)
#24 0x0000556e3bef544f
clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&,
llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&) const
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x3cf544f)
#25 0x0000556e3befe885
clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&,
llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x3cfe885)
#26 0x0000556e393e71de main
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x11e71de)
#27 0x00007fd94d98f0b3 __libc_start_main
(/lib/x86_64-linux-gnu/libc.so.6+0x270b3)
#28 0x0000556e394d2dda _start
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x12d2dda)
clang-14: error: clang frontend command failed with exit code 139 (use -v to
see invocation)
ASM generation compiler returned: 139</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>