[llvm-bugs] [Bug 52149] New: Crash when attempting to use export template specialization while not in module

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Oct 11 21:47:22 PDT 2021


https://bugs.llvm.org/show_bug.cgi?id=52149

            Bug ID: 52149
           Summary: Crash when attempting to use export template
                    specialization while not in module
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++2a
          Assignee: unassignedclangbugs at nondot.org
          Reporter: gabravier at gmail.com
                CC: blitzrakete at gmail.com, erik.pilkington at gmail.com,
                    llvm-bugs at lists.llvm.org, richard-llvm at metafoo.co.uk

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 https://bugs.llvm.org/ 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>
>, std::__cxx11::basic_string<char, std::char_traits<char>,
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>
>, std::__cxx11::basic_string<char, std::char_traits<char>,
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:
https://godbolt.org/z/arx5rh6rc

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20211012/37cfa562/attachment.html>


More information about the llvm-bugs mailing list