<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 - Crash when attempting to use export template specialization while not in module"
   href="https://bugs.llvm.org/show_bug.cgi?id=52149">52149</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Crash when attempting to use export template specialization while not in module
          </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>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++2a
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>gabravier@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>template <class T>
class f {
};

export template <class T> f<T>::i =

Gives me this beautiful error:

<source>:5:1: error: export declaration can only be used within a module
interface unit after the module declaration
export template <class T> f<T>::i =
^
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 <source>
1.      <source>:5:35: current parser token '='
 #0 0x00005624d8da7bef PrintStackTraceSignalHandler(void*) Signals.cpp:0:0
 #1 0x00005624d8da5ab0 llvm::sys::CleanupOnSignal(unsigned long)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x35a5ab0)
 #2 0x00005624d8cf5878 CrashRecoverySignalHandler(int)
CrashRecoveryContext.cpp:0:0
 #3 0x00007f9458fc53c0 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x153c0)
 #4 0x00007f9458aec055 __libc_realloc (/lib/x86_64-linux-gnu/libc.so.6+0x9e055)
 #5 0x00005624d8d19b2a llvm::SmallVectorBase<unsigned int>::grow_pod(void*,
unsigned long, unsigned long)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x3519b2a)
 #6 0x00005624d8cfd9fe llvm::FoldingSetNodeID::AddPointer(void const*)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x34fd9fe)
 #7 0x00005624db60bc42
clang::FormatASTNodeDiagnosticArgument(clang::DiagnosticsEngine::ArgumentKind,
long, llvm::StringRef, llvm::StringRef,
llvm::ArrayRef<std::pair<clang::DiagnosticsEngine::ArgumentKind, long> >,
llvm::SmallVectorImpl<char>&, void*, llvm::ArrayRef<long>)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x5e0bc42)
 #8 0x00005624d904dacc clang::Diagnostic::FormatDiagnostic(char const*, char
const*, llvm::SmallVectorImpl<char>&) const
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x384dacc)
 #9 0x00005624d97339e5
clang::TextDiagnosticPrinter::HandleDiagnostic(clang::DiagnosticsEngine::Level,
clang::Diagnostic const&)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x3f339e5)
#10 0x00005624d905bb84
clang::DiagnosticIDs::ProcessDiag(clang::DiagnosticsEngine&) const
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x385bb84)
#11 0x00005624d904d373 clang::DiagnosticsEngine::EmitCurrentDiagnostic(bool)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x384d373)
#12 0x00005624daca9551 clang::Sema::EmitCurrentDiagnostic(unsigned int)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x54a9551)
#13 0x00005624daca9878
clang::Sema::ImmediateDiagBuilder::~ImmediateDiagBuilder()
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x54a9878)
#14 0x00005624daca9dec
clang::Sema::SemaDiagnosticBuilder::~SemaDiagnosticBuilder()
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x54a9dec)
#15 0x00005624dade3c8b
clang::Sema::diagnoseQualifiedDeclaration(clang::CXXScopeSpec&,
clang::DeclContext*, clang::DeclarationName, clang::SourceLocation, bool)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x55e3c8b)
#16 0x00005624dae1f16c clang::Sema::HandleDeclarator(clang::Scope*,
clang::Declarator&, llvm::MutableArrayRef<clang::TemplateParameterList*>)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x561f16c)
#17 0x00005624db269a6a clang::Sema::ActOnTemplateDeclarator(clang::Scope*,
llvm::MutableArrayRef<clang::TemplateParameterList*>, clang::Declarator&)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x5a69a6a)
#18 0x00005624dababc91
clang::Parser::ParseDeclarationAfterDeclaratorAndAttributes(clang::Declarator&,
clang::Parser::ParsedTemplateInfo const&, clang::Parser::ForRangeInit*)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x53abc91)
#19 0x00005624dabb4b31
clang::Parser::ParseDeclarationAfterDeclarator(clang::Declarator&,
clang::Parser::ParsedTemplateInfo const&)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x53b4b31)
#20 0x00005624dac5f55e
clang::Parser::ParseSingleDeclarationAfterTemplate(clang::DeclaratorContext,
clang::Parser::ParsedTemplateInfo const&, clang::ParsingDeclRAIIObject&,
clang::SourceLocation&, clang::ParsedAttributes&, clang::AccessSpecifier)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x545f55e)
#21 0x00005624dac63374
clang::Parser::ParseTemplateDeclarationOrSpecialization(clang::DeclaratorContext,
clang::SourceLocation&, clang::ParsedAttributes&, clang::AccessSpecifier)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x5463374)
#22 0x00005624dac63ce4
clang::Parser::ParseDeclarationStartingWithTemplate(clang::DeclaratorContext,
clang::SourceLocation&, clang::ParsedAttributes&, clang::AccessSpecifier)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x5463ce4)
#23 0x00005624dabbdd75
clang::Parser::ParseDeclaration(clang::DeclaratorContext,
clang::SourceLocation&, clang::ParsedAttributesWithRange&,
clang::SourceLocation*)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x53bdd75)
#24 0x00005624dab955fb
clang::Parser::ParseExternalDeclaration(clang::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x53955fb)
#25 0x00005624dabd0ae5 clang::Parser::ParseExportDeclaration()
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x53d0ae5)
#26 0x00005624dab95736
clang::Parser::ParseExternalDeclaration(clang::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x5395736)
#27 0x00005624dab969f9
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, bool)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x53969f9)
#28 0x00005624dab8a289 clang::ParseAST(clang::Sema&, bool, bool)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x538a289)
#29 0x00005624d9d4c6a2 clang::CodeGenAction::ExecuteAction()
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x454c6a2)
#30 0x00005624d96ddf71 clang::FrontendAction::Execute()
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x3eddf71)
#31 0x00005624d967a8c2
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x3e7a8c2)
#32 0x00005624d97ab363
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x3fab363)
#33 0x00005624d6ad4d4c cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x12d4d4c)
#34 0x00005624d6ad0f5d ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&)
driver.cpp:0:0
#35 0x00005624d951d125 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
#36 0x00005624d8cf5e63
llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x34f5e63)
#37 0x00005624d951f1de
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+++0x3d1f1de)
#38 0x00005624d94f4a4a
clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&,
clang::driver::Command const*&) const
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x3cf4a4a)
#39 0x00005624d94f558f
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+++0x3cf558f)
#40 0x00005624d94fe9c5
clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&,
llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x3cfe9c5)
#41 0x00005624d69e50ce main
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x11e50ce)
#42 0x00007f9458a750b3 __libc_start_main
(/lib/x86_64-linux-gnu/libc.so.6+0x270b3)
#43 0x00005624d6ad0ada _start
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x12d0ada)
clang-14: error: clang frontend command failed with exit code 139 (use -v to
see invocation)

(I could not quite get all the information needed off Godbolt, but it seems
easy enough to reproduce)

Also here's a Godbolt link, I guess it might be useful:
<a href="https://godbolt.org/z/arx5rh6rc">https://godbolt.org/z/arx5rh6rc</a></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>