You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[clang-tidy] modernize-loop-convert: loops not detected when the iterator type has a non-trivial destructor #234990
version: clang-tidy 22.1.6 on x64 windows (also reproduced on osx arm64 with the same version)
structIt {
int *p;
~It() {} // remove this line and the loop is flaggedint &operator*() const { return *p; }
It &operator++() { ++p; return *this; }
booloperator!=(It const &o) const { return p != o.p; }
};
structC {
int d[4];
It begin() { return {d}; }
It end() { return {d + 4}; }
};
intf(C &c) {
int s = 0;
for (It it = c.begin(); it != c.end(); ++it) s += *it;
return s;
}
expected: use range-based for loop instead
actual: no output (also at MinConfidence: risky). Without the destructor, the warning appears.
MSVC STL with _ITERATOR_DEBUG_LEVEL=2 (default for debug builds) gives all standard iterators a nontrivial destructor so the check never fires on any iterator loop in Windows debug builds levels 0 and 1 work.
Details
version: clang-tidy 22.1.6 on x64 windows (also reproduced on osx arm64 with the same version)
structIt {
int *p;
~It() {} // remove this line and the loop is flaggedint &operator*() const { return *p; }
It &operator++() { ++p; return *this; }
booloperator!=(It const &o) const { return p != o.p; }
};
structC {
int d[4];
It begin() { return {d}; }
It end() { return {d + 4}; }
};
intf(C &c) {
int s = 0;
for (It it = c.begin(); it != c.end(); ++it) s += *it;
return s;
}
Activity
llvmorg-github-actions commentedon Oct 23, 2026
@llvm/issue-subscribers-clang-tidy
Author: kmate19
Details
version: clang-tidy 22.1.6 on x64 windows (also reproduced on osx arm64 with the same version)clang-tidy --checks='-*,modernize-loop-convert' dtor.cpp -- -std=c++20expected:
use range-based for loop insteadactual:** no output (also atMinConfidence: risky). Without the destructor, the warning appears.yashaggarwal85d commentedon Oct 27, 2026
Hi I would like to take this one, almost have a PR ready