[Bug c++/68816] gcc fails to detect pointer overflow leading to undefined behaviour
manu at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Wed Dec 9 16:58:00 GMT 2015
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68816
Manuel López-Ibáñez <manu at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2015-12-09
CC| |manu at gcc dot gnu.org
Ever confirmed|0 |1
--- Comment #3 from Manuel López-Ibáñez <manu at gcc dot gnu.org> ---
(In reply to David Binderman from comment #2)
> Not sure what you are saying here, but I was rather hoping that
> gcc could detect pointer + unsigned < same pointer and issue
> a warning message about relying on undefined behaviour.
I think the FE could detect this yes, but currently it does not. By the time
the code reaches the middle-end, the comparison is still there. Perhaps it can
be implemented in shorten_compare as part of -Wtype-limits. Currently those
warnings only work when comparing against a constant. Note that people using
-fwrapv may expect no warning.
You provided useful patches in the past. Perhaps you can figure out this one.
Unfortunately, I don't have as much free time as I used to.
More information about the Gcc-bugs
mailing list