This seems to be a false positive: (using 2.19.0) vector<int> vec; ... for(auto it = vec.begin(); it != vec.end();) { ... do { ... if(++it == vec.end()) break; } while(*it == 123); ... } warning: Either the condition 'it!=prev.end()' is redundant or there is possible dereference of an invalid iterator: it. [derefInvalidIteratorRedundantCheck] } while(it == 123); ^note: Assuming that condition 'it!=prev.end()' is not redundant for(auto it = vec.begin(); it != vec.end();) { ^note: Dereference of an...
This seems to be a false positive: (using 2.19.0) vector<int> vec; ... for(auto it = vec.begin(); it != vec.end();) { ... do { ... if(++it == vec.end()) break; } while(*it == 123); ... } warning: Either the condition 'it!=prev.end()' is redundant or there is possible dereference of an invalid iterator: it. [derefInvalidIteratorRedundantCheck] } while(it == 123); ^note: Assuming that condition 'it!=prev.end()' is not redundant for(auto it = vec.begin(); it != vec.end();) { ^note: Dereference of an...
I switched to version 2.19.0 and this issue is fixed.
It looks like I was running a much older version (v2.13.0 from 2023) because that is what Ubuntu apt install gives currently. But I have now manually installed v2.19.0 and this issue is fixed.
I think this is a false positive. template <typename T> constexpr T func(const T n) { if constexpr(std::is_signed_v<T>) if(n < 0) throw out_of_range(" n < 0 not allowed!"); ... } style: Checking if unsigned expression 'n' is less than zero. [unsignedLessThanZero] if(n < 0) throw out_of_range("n < 0 not allowed!"); -Doug
2.13.0
I think this is a false positive. class Foo { static constexpr size_t DEPTH = 4; std::array<T, DEPTH+1> arr; [[noreturn]] my_exit() { exit(1); } public: const T* func(const unsigned int n) const { if(n > DEPTH) my_exit(); return &arr[n]; } } warning: Either the condition 'n>DEPTH' is redundant or 'n' can have the value 4. Expression 'arr[n]' cause access out of bounds. [containerOutOfBounds] return &arr[n]; ^ There might also be a typo in the error message as here the array index can range from 0...
I think this is a false positive. class Foo { static constexpr size_t DEPTH = 4; std::array<t, depth+1=""> arr;</t,> [[noreturn]] my_exit() { exit(1); } public: const T* func(const unsigned int n) const { if(n > DEPTH) my_exit(); return &arr[n]; } } warning: Either the condition 'n>DEPTH' is redundant or 'n' can have the value 4. Expression 'arr[n]' cause access out of bounds. [containerOutOfBounds] return &arr[n]; ^ There might also be a typo in the error message as here the array index can range...