<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/79745>79745</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Front end crash on short (66 byte) code snippet
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          tonyelewis
      </td>
    </tr>
</table>

<pre>
    Running `clang++ a.cpp` with up to date build (`987087df90026605fc8d03ebda5a1cd31b71e609`, 2024-01-23) on:

~~~cpp
template <typename = int> struct a;
auto f() {
        a c;
        return c;
}
~~~

(demonstrated: https://godbolt.org/z/4jv8E7ns8)

&hellip;gives:

~~~
a.cpp:3:4: error: implicit instantiation of undefined template 'a<>'
    3 | a c;
      |           ^
a.cpp:1:34: note: template is declared here
    1 | template <typename = int> struct a;
      | ^
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.      Program arguments: /the-llvm-dir/bin/clang-19 -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -mrelax-all -dumpdir a- -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name a.cpp -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/tmp -fcoverage-compilation-dir=/tmp -resource-dir /the-llvm-dir/lib/clang/19 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/12/../../../../include/x86_64-linux-gnu/c++/12 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/backward -internal-isystem /the-llvm-dir/lib/clang/19/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/12/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -fdeprecated-macro -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/a-a3d6fd.o -x c++ a.cpp
1.      a.cpp:4:10: current parser token ';'
2.      a.cpp:2:10: parsing function body 'f'
3.      a.cpp:2:10: in compound statement ('{}')
 #0 0x000055ec1be34450 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/the-llvm-dir/bin/clang-19+0x37c5450)
 #1 0x000055ec1be31a1e SignalHandler(int) Signals.cpp:0:0
 #2 0x00007fc8d5e42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #3 0x000055ec1f08070c clang::ASTContext::getASTRecordLayout(clang::RecordDecl const*) const (/the-llvm-dir/bin/clang-19+0x6a1170c)
 #4 0x000055ec1ec1d0c4 clang::ASTContext::getTypeInfoImpl(clang::Type const*) const (/the-llvm-dir/bin/clang-19+0x65ae0c4)
 #5 0x000055ec1ec06f42 clang::ASTContext::getTypeInfo(clang::Type const*) const (/the-llvm-dir/bin/clang-19+0x6597f42)
 #6 0x000055ec1ec06f42 clang::ASTContext::getTypeInfo(clang::Type const*) const (/the-llvm-dir/bin/clang-19+0x6597f42)
 #7 0x000055ec1ec06f42 clang::ASTContext::getTypeInfo(clang::Type const*) const (/the-llvm-dir/bin/clang-19+0x6597f42)
 #8 0x000055ec1ec1d729 clang::ASTContext::getTypeAlignInChars(clang::QualType) const (/the-llvm-dir/bin/clang-19+0x65ae729)
 #9 0x000055ec1e71591c clang::Sema::getNamedReturnInfo(clang::VarDecl const*) (/the-llvm-dir/bin/clang-19+0x60a691c)
#10 0x000055ec1e7159a2 clang::Sema::getNamedReturnInfo(clang::Expr*&, clang::Sema::SimplerImplicitMoveMode) (/the-llvm-dir/bin/clang-19+0x60a69a2)
#11 0x000055ec1e73e0a4 clang::Sema::BuildReturnStmt(clang::SourceLocation, clang::Expr*, bool) (/the-llvm-dir/bin/clang-19+0x60cf0a4)
#12 0x000055ec1e73f8c7 clang::Sema::ActOnReturnStmt(clang::SourceLocation, clang::Expr*, clang::Scope*) (/the-llvm-dir/bin/clang-19+0x60d08c7)
#13 0x000055ec1df53718 clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*, clang::ParsedAttributes&, clang::ParsedAttributes&) (/the-llvm-dir/bin/clang-19+0x58e4718)
#14 0x000055ec1df546c8 clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*) (/the-llvm-dir/bin/clang-19+0x58e56c8)
#15 0x000055ec1df554c1 clang::Parser::ParseCompoundStatementBody(bool) (/the-llvm-dir/bin/clang-19+0x58e64c1)
#16 0x000055ec1df5844a clang::Parser::ParseFunctionStatementBody(clang::Decl*, clang::Parser::ParseScope&) (/the-llvm-dir/bin/clang-19+0x58e944a)
#17 0x000055ec1de73ae6 clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*) (/the-llvm-dir/bin/clang-19+0x5804ae6)
#18 0x000055ec1dead3df clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::ParsedAttributes&, clang::SourceLocation*, clang::Parser::ForRangeInit*) (/the-llvm-dir/bin/clang-19+0x583e3df)
#19 0x000055ec1de6e4f6 clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) (/the-llvm-dir/bin/clang-19+0x57ff4f6)
#20 0x000055ec1de75c42 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/the-llvm-dir/bin/clang-19+0x5806c42)
#21 0x000055ec1de77627 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/the-llvm-dir/bin/clang-19+0x5808627)
#22 0x000055ec1de67d2a clang::ParseAST(clang::Sema&, bool, bool) (/the-llvm-dir/bin/clang-19+0x57f8d2a)
#23 0x000055ec1c8c6b31 clang::FrontendAction::Execute() (/the-llvm-dir/bin/clang-19+0x4257b31)
#24 0x000055ec1c8454f9 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/the-llvm-dir/bin/clang-19+0x41d64f9)
#25 0x000055ec1c989113 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/the-llvm-dir/bin/clang-19+0x431a113)
#26 0x000055ec194cc833 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/the-llvm-dir/bin/clang-19+0xe5d833)
#27 0x000055ec194c4c9d ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#28 0x000055ec194c88fa clang_main(int, char**, llvm::ToolContext const&) (/the-llvm-dir/bin/clang-19+0xe598fa)
#29 0x000055ec193c9e9b main (/the-llvm-dir/bin/clang-19+0xd5ae9b)
#30 0x00007fc8d5e29d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
#31 0x00007fc8d5e29e40 call_init ./csu/../csu/libc-start.c:128:20
#32 0x00007fc8d5e29e40 __libc_start_main ./csu/../csu/libc-start.c:379:5
#33 0x000055ec194c4115 _start (/the-llvm-dir/bin/clang-19+0xe55115)
clang++: error: unable to execute command: Segmentation fault (core dumped)
clang++: error: clang frontend command failed due to signal (use -v to see invocation)
clang version 19.0.0git (https://github.com/llvm/llvm-project.git 987087df90026605fc8d03ebda5a1cd31b71e609)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /the-llvm-dir/bin
clang++: note: diagnostic msg: 
********************

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

********************
~~~

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzMWsty2zizfhp4g6KKBO8LL2TJSlzljHMsn5mlCwKaFCYkwAOAjn0W8-x_AdSNsuJYzvxT40okCkR3f93oGwFSY0QtAS5ReoXS-QXt7VrpS6vkCzTwXZiLleIvl_e9lELWGGUha6isEblC5ArTCes6lIX4u7Br3HfYKsypBbzqRcMxIgXKwrLIwyLnVRmGJMvCtGIFD2NYcZrSiPE4WuURZGGJshCRGSYhSYIwCkiMSImVRPEUhXMUbj7_-usvJ9NfW2i7xolD8cy-dCBp667nWEiL4mtsrO6ZxRTFVwMB7a3ClYNFSozyqy3jkmK2m4TCUoPttTwcy-c78YdoECk4tEoaq6kFjuIpXlvbGQeaLBBZ1IqvVGMnSteILP4fkUXy51NxnUvjMIxZZWtoGtGh-KoWT2BeK75Rwhs9nsYoniZOImittLsQbdcIJiwW0lgqraBWKIlVhXvJoRISON7bjOQUxTMUXyOSD5wxxjjGKJ_hQ3tg_-dG938ovR6DiRwgj0YqC-57J0gYzIE1VAPHa9Cw5xp5rmev4h7QDsbX2-vp8hqbftUKiyle9TXW0CltnUseLYmw6341YapFZNE0T9uvoNPqT2AWkYUwpgeDyAJTybGQrOk5YLsGzDQ1a7yi7JvVlIFz2E5DpxUDY4Bjo3o9DDtKaoxiwnkG1r3EhmnR2ckAeWkp-4Z533a7hQ4nKCy_alVr2mKq674FaR1wjMjCriHwMLnQiCxWQiKy8MEYRCUOGItwYLXoGsDPRfaYJUEvv0n1XQaNkP1zUMseB9AKG6jVnzhoNTT0OaBNgwMHgguNaYADLgxdNRBUGgAHrAGqA2pssIJKaQic5iD5fp6H9ARaVAK0H2ZU8-CJNj0EbikNDloqZFCJZhgYss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