https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118155
Bug ID: 118155
Summary: Extend -Wtautological-compare for pointer addition
Product: gcc
Version: 15.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: mpolacek at gcc dot gnu.org
Target Milestone: ---
For
```
using size_t = decltype(sizeof(0));
bool incorrect_overflow_check(const char *ptr, size_t index) {
return ptr + index < ptr; // warning
}
```
clang++ now emits:
q.C:3:24: warning: pointer comparison always evaluates to false
[-Wtautological-compare]
3 | return ptr + index < ptr; // warning
| ^
We should consider implementing this for GCC 16.
See https://github.com/llvm/llvm-project/pull/120222/files for more details.