Description
Running clang-tidy with -checks='-*,modernize-use-integer-sign-comparison' and '-std=c++20' (or above) on the code
struct A
{
unsigned size() const;
};
struct B
{
A a;
bool foo(const A& a2) const { return (int)a2.size() == size(); }
int size() const { return (int)a.size(); }
};
triggers an assertion: clang-tidy: /tmp/LLVM/llvm-project/clang-tools-extra/clang-tidy/modernize/UseIntegerSignComparisonCheck.cpp:123: virtual void clang::tidy::modernize::UseIntegerSignComparisonCheck::check(const clang::ast_matchers::MatchFinder::MatchResult&): Assertion 'SignedCastExpression' failed.
This was introduced in the last two weeks, so I suspect this is due to the fix for #127471 .
@RiverDave , @vbvictor : Could you please have a look?
Activity
llvmbot commentedon Jun 12, 2025
@llvm/issue-subscribers-clang-tidy
Author: None (VReichelt)
triggers an assertion:
clang-tidy: /tmp/LLVM/llvm-project/clang-tools-extra/clang-tidy/modernize/UseIntegerSignComparisonCheck.cpp:123: virtual void clang::tidy::modernize::UseIntegerSignComparisonCheck::check(const clang::ast_matchers::MatchFinder::MatchResult&): Assertion 'SignedCastExpression' failed.
This was introduced in the last two weeks, so I suspect this is due to the fix for #127471 .
@RiverDave , @vbvictor : Could you please have a look?
Stacktrace.txt
EugeneZelenko commentedon Jun 12, 2025
See https://godbolt.org/z/GhYMc6Wbs
RiverDave commentedon Jun 12, 2025
Taking a look at this as soon as I have the time
vbvictor commentedon Jun 12, 2025
Thank you for the quick catch of the bug.
I think we need to revert the changes.
vbvictor commentedon Jun 12, 2025
@RiverDave , you could create a revert pr if you wish (I see you got member!), or I can do it in 2-3 hours
RiverDave commentedon Jun 12, 2025
Done. as a side note what is the general procedure when catching these bugs? I mean once the revert is done, under which issue should everything be resolved?
Revert "[clang-tidy] Improve integer comparison by matching valid exp…
Automerge: Revert "[clang-tidy] Improve integer comparison by matchin…
vbvictor commentedon Jun 12, 2025
I'm not 100% sure, but you may reopen previously closed issue and when reapplying fix mention both issues.
5 remaining items