Bug 454757 - strict-iterator false positive when calling a const member function through operator->
Summary: strict-iterator false positive when calling a const member function through o...
Status: REPORTED
Alias: None
Product: clazy
Classification: Developer tools
Component: general (show other bugs)
Version: unspecified
Platform: Other Microsoft Windows
: NOR normal
Target Milestone: ---
Assignee: Unassigned bugs mailing-list
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-06-02 16:59 UTC by julien.cugniere
Modified: 2022-06-02 16:59 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description julien.cugniere 2022-06-02 16:59:19 UTC
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.