[clazy] [Bug 454757] New: strict-iterator false positive when calling a const member function through operator->

bugzilla_noreply at kde.org bugzilla_noreply at kde.org
Thu Jun 2 17:59:19 BST 2022


https://bugs.kde.org/show_bug.cgi?id=454757

            Bug ID: 454757
           Summary: strict-iterator false positive when calling a const
                    member function through operator->
           Product: clazy
           Version: unspecified
          Platform: Other
                OS: Microsoft Windows
            Status: REPORTED
          Severity: normal
          Priority: NOR
         Component: general
          Assignee: unassigned-bugs at kde.org
          Reporter: julien.cugniere at gmail.com
                CC: smartins at kde.org
  Target Milestone: ---

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.

-- 
You are receiving this mail because:
You are the assignee for the bug.


More information about the Unassigned-bugs mailing list