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

    <tr>
        <th>Summary</th>
        <td>
            [clang-tidy][error] numeric literal operator template causes `SIGSEGV` with `readability-container-size-empty` check
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang-tidy
      </td>
    </tr>

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

    <tr>
      <th>Reporter</th>
      <td>
          r-braun
      </td>
    </tr>
</table>

<pre>
    Consider the following code using a numeric literal operator template:

```c++
template <char...>
int operator""_ci() { return 0; }

auto eq = 0_ci == 0;
```
Running `clang-tidy-18` with `-check='readability-container-size-empty'` results in a `SIGSEGV` (see output at the bottom).
The same happens with `0_ci != 0`, but doesn't happen for other operators (i.e. `0_ci < 0` or `0_ci + 0`) or when prefixing the literal (i.e. `-0_ci == 0` or `+0_ci == 0`). 
Reversing the order also fixes the error:
```c++
// works as expected
auto eq = 0 == 0_ci;
```
[Link to Compiler Explorer](https://godbolt.org/z/zWGavYs86) using `clang-tidy (trunk)`.

`clang-tidy-18` Output:
```
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.      Program arguments: /clang-tidy -checks=readability-container-size-empty <source>
1.      <eof> parser at end of file
2.      ASTMatcher: Matching 'readability-container-size-empty' against:
        BinaryOperator : <<source>:4:11, col:19>
 #0 0x00000000050054e8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/clang-tidy+0x50054e8)
 #1 0x0000000005002e5c SignalHandler(int) Signals.cpp:0:0
 #2 0x000074ac56c42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #3 0x0000000003c8cf70 clang::ASTNodeKind::getFromNode(clang::Stmt const&) (/clang-tidy+0x3c8cf70)
 #4 0x000000000124b901 clang::ast_matchers::internal::MatcherInterface<clang::UserDefinedLiteral>::dynMatches(clang::DynTypedNode const&, clang::ast_matchers::internal::ASTMatchFinder*, clang::ast_matchers::internal::BoundNodesTreeBuilder*) const (/clang-tidy+0x124b901)
 #5 0x0000000003b0daae clang::ast_matchers::internal::DynTypedMatcher::matches(clang::DynTypedNode const&, clang::ast_matchers::internal::ASTMatchFinder*, clang::ast_matchers::internal::BoundNodesTreeBuilder*) const (/clang-tidy+0x3b0daae)
 #6 0x0000000003b0fe49 clang::ast_matchers::internal::(anonymous namespace)::VariadicMatcher<&clang::ast_matchers::internal::anyOfVariadicOperator(clang::DynTypedNode const&, clang::ast_matchers::internal::ASTMatchFinder*, clang::ast_matchers::internal::BoundNodesTreeBuilder*, llvm::ArrayRef<clang::ast_matchers::internal::DynTypedMatcher>)>::dynMatches(clang::DynTypedNode const&, clang::ast_matchers::internal::ASTMatchFinder*, clang::ast_matchers::internal::BoundNodesTreeBuilder*) const ASTMatchersInternal.cpp:0:0
 #7 0x0000000003b0daae clang::ast_matchers::internal::DynTypedMatcher::matches(clang::DynTypedNode const&, clang::ast_matchers::internal::ASTMatchFinder*, clang::ast_matchers::internal::BoundNodesTreeBuilder*) const (/clang-tidy+0x3b0daae)
 #8 0x0000000000bab300 clang::ast_matchers::internal::matcher_hasLHS0Matcher<clang::BinaryOperator, clang::ast_matchers::internal::Matcher<clang::Expr>>::matches(clang::BinaryOperator const&, clang::ast_matchers::internal::ASTMatchFinder*, clang::ast_matchers::internal::BoundNodesTreeBuilder*) const (/clang-tidy+0xbab300)
 #9 0x0000000003b0d7e1 clang::ast_matchers::internal::DynTypedMatcher::matchesNoKindCheck(clang::DynTypedNode const&, clang::ast_matchers::internal::ASTMatchFinder*, clang::ast_matchers::internal::BoundNodesTreeBuilder*) const (/clang-tidy+0x3b0d7e1)
#10 0x0000000003b0d98e clang::ast_matchers::internal::(anonymous namespace)::VariadicMatcher<&clang::ast_matchers::internal::allOfVariadicOperator(clang::DynTypedNode const&, clang::ast_matchers::internal::ASTMatchFinder*, clang::ast_matchers::internal::BoundNodesTreeBuilder*, llvm::ArrayRef<clang::ast_matchers::internal::DynTypedMatcher>)>::dynMatches(clang::DynTypedNode const&, clang::ast_matchers::internal::ASTMatchFinder*, clang::ast_matchers::internal::BoundNodesTreeBuilder*) const ASTMatchersInternal.cpp:0:0
#11 0x0000000003b0daae clang::ast_matchers::internal::DynTypedMatcher::matches(clang::DynTypedNode const&, clang::ast_matchers::internal::ASTMatchFinder*, clang::ast_matchers::internal::BoundNodesTreeBuilder*) const (/clang-tidy+0x3b0daae)
#12 0x0000000003b0fe49 clang::ast_matchers::internal::(anonymous namespace)::VariadicMatcher<&clang::ast_matchers::internal::anyOfVariadicOperator(clang::DynTypedNode const&, clang::ast_matchers::internal::ASTMatchFinder*, clang::ast_matchers::internal::BoundNodesTreeBuilder*, llvm::ArrayRef<clang::ast_matchers::internal::DynTypedMatcher>)>::dynMatches(clang::DynTypedNode const&, clang::ast_matchers::internal::ASTMatchFinder*, clang::ast_matchers::internal::BoundNodesTreeBuilder*) const ASTMatchersInternal.cpp:0:0
#13 0x0000000003b0daae clang::ast_matchers::internal::DynTypedMatcher::matches(clang::DynTypedNode const&, clang::ast_matchers::internal::ASTMatchFinder*, clang::ast_matchers::internal::BoundNodesTreeBuilder*) const (/clang-tidy+0x3b0daae)
#14 0x0000000000bdd0f6 clang::ast_matchers::internal::matcher_hasOperands0Matcher<clang::BinaryOperator, clang::ast_matchers::internal::Matcher<clang::Expr>, clang::ast_matchers::internal::Matcher<clang::Expr>>::matches(clang::BinaryOperator const&, clang::ast_matchers::internal::ASTMatchFinder*, clang::ast_matchers::internal::BoundNodesTreeBuilder*) const (/clang-tidy+0xbdd0f6)
#15 0x0000000003b0d7e1 clang::ast_matchers::internal::DynTypedMatcher::matchesNoKindCheck(clang::DynTypedNode const&, clang::ast_matchers::internal::ASTMatchFinder*, clang::ast_matchers::internal::BoundNodesTreeBuilder*) const (/clang-tidy+0x3b0d7e1)
#16 0x0000000003b0d895 clang::ast_matchers::internal::(anonymous namespace)::VariadicMatcher<&clang::ast_matchers::internal::allOfVariadicOperator(clang::DynTypedNode const&, clang::ast_matchers::internal::ASTMatchFinder*, clang::ast_matchers::internal::BoundNodesTreeBuilder*, llvm::ArrayRef<clang::ast_matchers::internal::DynTypedMatcher>)>::dynMatches(clang::DynTypedNode const&, clang::ast_matchers::internal::ASTMatchFinder*, clang::ast_matchers::internal::BoundNodesTreeBuilder*) const ASTMatchersInternal.cpp:0:0
#17 0x0000000003b0daae clang::ast_matchers::internal::DynTypedMatcher::matches(clang::DynTypedNode const&, clang::ast_matchers::internal::ASTMatchFinder*, clang::ast_matchers::internal::BoundNodesTreeBuilder*) const (/clang-tidy+0x3b0daae)
#18 0x0000000003b0fe49 clang::ast_matchers::internal::(anonymous namespace)::VariadicMatcher<&clang::ast_matchers::internal::anyOfVariadicOperator(clang::DynTypedNode const&, clang::ast_matchers::internal::ASTMatchFinder*, clang::ast_matchers::internal::BoundNodesTreeBuilder*, llvm::ArrayRef<clang::ast_matchers::internal::DynTypedMatcher>)>::dynMatches(clang::DynTypedNode const&, clang::ast_matchers::internal::ASTMatchFinder*, clang::ast_matchers::internal::BoundNodesTreeBuilder*) const ASTMatchersInternal.cpp:0:0
#19 0x0000000003b0f281 clang::ast_matchers::internal::(anonymous namespace)::IdDynMatcher::dynMatches(clang::DynTypedNode const&, clang::ast_matchers::internal::ASTMatchFinder*, clang::ast_matchers::internal::BoundNodesTreeBuilder*) const ASTMatchersInternal.cpp:0:0
#20 0x0000000003b0daae clang::ast_matchers::internal::DynTypedMatcher::matches(clang::DynTypedNode const&, clang::ast_matchers::internal::ASTMatchFinder*, clang::ast_matchers::internal::BoundNodesTreeBuilder*) const (/clang-tidy+0x3b0daae)
#21 0x0000000000bb3068 clang::ast_matchers::internal::TraversalMatcher<clang::Stmt>::matches(clang::Stmt const&, clang::ast_matchers::internal::ASTMatchFinder*, clang::ast_matchers::internal::BoundNodesTreeBuilder*) const (/clang-tidy+0xbb3068)
#22 0x0000000003b0daae clang::ast_matchers::internal::DynTypedMatcher::matches(clang::DynTypedNode const&, clang::ast_matchers::internal::ASTMatchFinder*, clang::ast_matchers::internal::BoundNodesTreeBuilder*) const (/clang-tidy+0x3b0daae)
#23 0x0000000003abe549 clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor::matchWithFilter(clang::DynTypedNode const&) ASTMatchFinder.cpp:0:0
#24 0x0000000003aefede clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor::TraverseStmt(clang::Stmt*, llvm::SmallVectorImpl<llvm::PointerIntPair<clang::Stmt*, 1u, bool, llvm::PointerLikeTypeTraits<clang::Stmt*>, llvm::PointerIntPairInfo<clang::Stmt*, 1u, llvm::PointerLikeTypeTraits<clang::Stmt*>>>>*) (.constprop.0) ASTMatchFinder.cpp:0:0
#25 0x0000000003aeb1c3 clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor::TraverseDecl(clang::Decl*) ASTMatchFinder.cpp:0:0
#26 0x0000000003aec559 clang::RecursiveASTVisitor<clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor>::TraverseDeclContextHelper(clang::DeclContext*) (.part.0) ASTMatchFinder.cpp:0:0
#27 0x0000000003af7555 clang::RecursiveASTVisitor<clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor>::TraverseTranslationUnitDecl(clang::TranslationUnitDecl*) ASTMatchFinder.cpp:0:0
#28 0x0000000003aeb1b0 clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor::TraverseDecl(clang::Decl*) ASTMatchFinder.cpp:0:0
#29 0x0000000003aebdc4 clang::ast_matchers::MatchFinder::matchAST(clang::ASTContext&) (/clang-tidy+0x3aebdc4)
#30 0x00000000027691a8 clang::MultiplexConsumer::HandleTranslationUnit(clang::ASTContext&) (/clang-tidy+0x27691a8)
#31 0x00000000029fdeac clang::ParseAST(clang::Sema&, bool, bool) (/clang-tidy+0x29fdeac)
#32 0x000000000272af71 clang::FrontendAction::Execute() (/clang-tidy+0x272af71)
#33 0x00000000026a938b clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/clang-tidy+0x26a938b)
#34 0x0000000001e5ae86 clang::tooling::FrontendActionFactory::runInvocation(std::shared_ptr<clang::CompilerInvocation>, clang::FileManager*, std::shared_ptr<clang::PCHContainerOperations>, clang::DiagnosticConsumer*) (/clang-tidy+0x1e5ae86)
#35 0x0000000001dfe83c clang::tidy::runClangTidy(clang::tidy::ClangTidyContext&, clang::tooling::CompilationDatabase const&, llvm::ArrayRef<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>, llvm::IntrusiveRefCntPtr<llvm::vfs::OverlayFileSystem>, bool, bool, llvm::StringRef)::ActionFactory::runInvocation(std::shared_ptr<clang::CompilerInvocation>, clang::FileManager*, std::shared_ptr<clang::PCHContainerOperations>, clang::DiagnosticConsumer*) ClangTidy.cpp:0:0
#36 0x0000000001e53f2c clang::tooling::ToolInvocation::runInvocation(char const*, clang::driver::Compilation*, std::shared_ptr<clang::CompilerInvocation>, std::shared_ptr<clang::PCHContainerOperations>) (/clang-tidy+0x1e53f2c)
#37 0x0000000001e55ff8 clang::tooling::ToolInvocation::run() (/clang-tidy+0x1e55ff8)
#38 0x0000000001e5927e clang::tooling::ClangTool::run(clang::tooling::ToolAction*) (/clang-tidy+0x1e5927e)
#39 0x0000000001e00c69 clang::tidy::runClangTidy(clang::tidy::ClangTidyContext&, clang::tooling::CompilationDatabase const&, llvm::ArrayRef<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>, llvm::IntrusiveRefCntPtr<llvm::vfs::OverlayFileSystem>, bool, bool, llvm::StringRef) (/clang-tidy+0x1e00c69)
#40 0x0000000000b82d0a clang::tidy::clangTidyMain(int, char const**) (/clang-tidy+0xb82d0a)
#41 0x000074ac56c29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#42 0x000074ac56c29e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#43 0x0000000000b79a9e _start (/clang-tidy+0xb79a9e)
Program terminated with signal: SIGSEGV
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsW11z4rjS_jXKjSqULWNjX-SCQNhJvTM7qYGdrfeKku026MRIPpKcgf31p-QPsAz5IGfP7swsU2QCltX99NPd6kaxqFJsxQFukH-L_OkVLfVayBt5HUta8qtYpLubieCKpSCxXgPORJ6Lb4yvcCJSwKUybynm5QYkS3DONEiaY1GApFpIrGFT5FQD8sbImSKn_T9w6leCyK15VVfbmzHyJsmaysFggLy7eoxxvZeKCEGELBOGSIhIhNHoFkvQpeTYQd4tRqNpVxkttcDwb4y8KXaWCTNvqvfIu-3BqT9-KTk3dhl8OeWra83S3bUbosDB35hem4HrZA3Jo5FERhJoSmOWM727TgTXlHGQ14r9AdewKfQOkZGZKkGVuVaYcUyNiPn9L_O7X76aIURCBYBFqYtSY6orrmOhtdggEg1qWIs1YEU3gNe0KICrPZbaKOLWRgUOIhMclxqnAhRHZKSbGTgTEgu9BrmnUhnVbACDgxxvUgnBQnZk3zaCI3P52xo4LiRkbGtoMlhbx3ekXdtc7yUictsfMTbihnt4AqlasUKawKO5EjhjW1DVRZBSyENAnQwlRGaIzPA3IR8VpgrDtoBEQ3oiIvZATEA9ExHIv_3I-CPWAk_EpmA5SHy3LXIhQSJ_iki41rpQBlSleCXSWOR6IOQKkdkf5uf3X-jT_6swMBzWaWOFl2FOy5I_IhKhwBn0suUoDj9XoXLMQv3x4ePdeH6HVRlvmMYUx-UKSyiE1MaEHlam12U8SEyozfL8qf11XUjxL0g0IjOmVAnKEEp5ihlP8jKFyheJpGqNY5o8akkTaGDPNU0ecVpuij1AY1H0IMVK0g2mclVugGsDAiMy69BQ55VC3vS1rDKRqkQpE9gvEq5RgrwJiAx5d7igUpnw0Rh4ikWGM5ZDfScxd47ni09UJ2sw0YSrt5Vf3pTRmK4o46rjAie6ZZzK3ed28aus8yYWTm88RN7YdU2OJiI376M9foyI52Bn67T_fMfxhxDiyi3eGHljtVP1mwfJuK6IXhjmEQkPN0n6bSmUlkA3iARGFe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