This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/81172] Expected new warning option -Warray-bounds-pointer-arithmetic
- From: "msebor at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 30 Jun 2017 15:02:04 +0000
- Subject: [Bug middle-end/81172] Expected new warning option -Warray-bounds-pointer-arithmetic
- Auto-submitted: auto-generated
- References: <bug-81172-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81172
Martin Sebor <msebor at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |diagnostic
Status|UNCONFIRMED |NEW
Last reconfirmed| |2017-06-30
CC| |msebor at gcc dot gnu.org
Ever confirmed|0 |1
--- Comment #4 from Martin Sebor <msebor at gcc dot gnu.org> ---
Confirmed. There are a few bug reports for missing -Warray-bounds warning that
might be worth reviewing as well (e.g., pr67872).
I'm not sure distinguishing between forming an out-of-bounds pointer by (a + 5)
vs dereferencing a past-the-end element by a[5] is necessary or even a good
idea. My concern with having distinct options for such closely related
problems is that it might be tricky to get their interaction right in cases
like (a + N) and &a[N]: should that trigger -Warray-bounds or
-Warray-bounds-pointer-arithmetic, what about when N is not a constant
expression?
Clang diagnoses the the cases where the offset or index is a constant
expression (and under the expected option) but it doesn't diagnose others where
the offset/index value is not a constant expression but can be determined to be
out of bounds by VRP, for instance. GCC can do better, but it may not be able
to distinguish between the two kinds of warnings outside the front end.