<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/62882>62882</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Clang crashes on user defined literal as NTTP
</td>
</tr>
<tr>
<th>Labels</th>
<td>
c++20,
clang:frontend,
crash-on-valid
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
usx95
</td>
</tr>
</table>
<pre>
GCC: `g++.dg/cpp2a/udlit-class-nttp.C`
https://godbolt.org/z/PvcPafdYr
```cpp
struct literal_class {
constexpr literal_class(...) { }
};
template <literal_class>
constexpr int operator"" _abc() {
return 1;
}
static_assert("test"_abc == 1);
```
```
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: /opt/compiler-explorer/clang-trunk/bin/clang++ -gdwarf-4 -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>:10:26: current parser token '=='
#0 0x000055a862570eef llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x360deef)
#1 0x000055a86256ef1c llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x360bf1c)
#2 0x000055a8624bfb08 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#3 0x00007f460a417420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
#4 0x000055a86532a77c clang::StandardConversionSequence::getNarrowingKind(clang::ASTContext&, clang::Expr const*, clang::APValue&, clang::QualType&, bool) const (/opt/compiler-explorer/clang-trunk/bin/clang+++0x63c777c)
#5 0x000055a865365539 CheckConvertedConstantExpression(clang::Sema&, clang::Expr*, clang::QualType, clang::APValue&, clang::Sema::CCEKind, bool, clang::NamedDecl*) SemaOverload.cpp:0:0
#6 0x000055a865365b92 clang::Sema::CheckConvertedConstantExpression(clang::Expr*, clang::QualType, clang::APValue&, clang::Sema::CCEKind, clang::NamedDecl*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x6402b92)
#7 0x000055a86542658f clang::Sema::CheckTemplateArgument(clang::NonTypeTemplateParmDecl*, clang::QualType, clang::Expr*, clang::TemplateArgument&, clang::TemplateArgument&, clang::Sema::CheckTemplateArgumentKind) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x64c358f)
#8 0x000055a86542836e clang::Sema::CheckTemplateArgument(clang::NamedDecl*, clang::TemplateArgumentLoc&, clang::NamedDecl*, clang::SourceLocation, clang::SourceLocation, unsigned int, llvm::SmallVectorImpl<clang::TemplateArgument>&, llvm::SmallVectorImpl<clang::TemplateArgument>&, clang::Sema::CheckTemplateArgumentKind) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x64c536e)
#9 0x000055a8651f77f6 clang::Sema::LookupLiteralOperator(clang::Scope*, clang::LookupResult&, llvm::ArrayRef<clang::QualType>, bool, bool, bool, bool, clang::StringLiteral*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x62947f6)
#10 0x000055a864fac4b0 clang::Sema::ActOnStringLiteral(llvm::ArrayRef<clang::Token>, clang::Scope*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x60494b0)
#11 0x000055a864b0d4a4 clang::Parser::ParseStringLiteralExpression(bool) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x5baa4a4)
#12 0x000055a864b120da clang::Parser::ParseCastExpression(clang::Parser::CastParseKind, bool, bool&, clang::Parser::TypeCastState, bool, bool*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x5baf0da)
#13 0x000055a864b204bd clang::Parser::ParseConstantExpressionInExprEvalContext(clang::Parser::TypeCastState) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x5bbd4bd)
#14 0x000055a864af87c6 clang::Parser::ParseStaticAssertDeclaration(clang::SourceLocation&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x5b957c6)
#15 0x000055a864ae7e9f clang::Parser::ParseDeclaration(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::ParsedAttributes&, clang::SourceLocation*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x5b84e9f)
#16 0x000055a864ab75ba clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x5b545ba)
#17 0x000055a864ab938b clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x5b5638b)
#18 0x000055a864aa88fa clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x5b458fa)
#19 0x000055a8636def35 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-trunk/bin/clang+++0x477bf35)
#20 0x000055a862fc9331 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-trunk/bin/clang+++0x4066331)
#21 0x000055a862f4d673 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3fea673)
#22 0x000055a8630a8603 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x4145603)
#23 0x000055a85fe0694c cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0xea394c)
#24 0x000055a85fe0204f ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#25 0x000055a862daa49d void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const::'lambda'()>(long) Job.cpp:0:0
#26 0x000055a8624bff87 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x355cf87)
#27 0x000055a862daa6dc clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (.part.0) Job.cpp:0:0
#28 0x000055a862d7211e clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3e0f11e)
#29 0x000055a862d72aed clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3e0faed)
#30 0x000055a862d7d1bc clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3e1a1bc)
#31 0x000055a85fe0454f clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0xea154f)
#32 0x000055a85fd022f5 main (/opt/compiler-explorer/clang-trunk/bin/clang+++0xd9f2f5)
#33 0x00007f4609ec5083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#34 0x000055a85fdfe32e _start (/opt/compiler-explorer/clang-trunk/bin/clang+++0xe9b32e)
clang++: error: clang frontend command failed with exit code 139 (use -v to see invocation)
Compiler returned: 139
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzkWs1y47gRfhr4gqKKBPh78EEj25vZODPOyLVVOalAoCEzpgAuAHrkPH0KJCULsi3vTjTJIVW7IxlooL_-utHdhMisbdYK4BJln1B2dcF696DNZW-3VXZRa_F8-ctigegcozxeI_IJkU8zsUbkhncdYYjc9KJtXMRbZm2knOtmC5THKL5C8fz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