| Summary: | strict-iterator false positive when calling a const member function through operator-> | ||
|---|---|---|---|
| Product: | [Developer tools] clazy | Reporter: | julien.cugniere |
| Component: | general | Assignee: | Unassigned bugs <unassigned-bugs-null> |
| Status: | REPORTED --- | ||
| Severity: | normal | CC: | julien.cugniere, smartins |
| Priority: | NOR | ||
| Version First Reported In: | unspecified | ||
| Target Milestone: | --- | ||
| Platform: | Other | ||
| OS: | Microsoft Windows | ||
| Latest Commit: | Version Fixed/Implemented In: | ||
| Sentry Crash Report: | |||
SUMMARY Clazy reports a spurious "Mixing iterators with const_iterators" when using iterator::operator-> to call a const member function. Using that same iterator to also call non-const member functions still produces the warning. STEPS TO REPRODUCE Apply clazy with "checks=strict-iterators" on the following file : ``` #include <QVector> int main() { QVector<QString> v = { "hello" }; QVector<QString>::iterator it = v.begin(); if (!it->isEmpty()) { it->clear(); } } ```` OBSERVED RESULT Clazy will report "Mixing iterators with const_iterators" on the "!it->isEmpty()" line. EXPECTED RESULT No warning should be produced. SOFTWARE/OS VERSIONS Qt Version: 5.15.2 Clazy: 1.11 ADDITIONAL INFORMATION Using "!(*it).isEmpty()" instead of "!it->isEmpty()" removes the warning.