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: "ryxi at stu dot xidian.edu.cn" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sat, 01 Jul 2017 04:14:21 +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
--- Comment #5 from Xi Ruoyao <ryxi at stu dot xidian.edu.cn> ---
(In reply to Martin Sebor from comment #4)
> 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.
I'm aware that GCC C/C++ FE convert a[x] to *(a+x) very early. But now it's
very strange - why GCC -Warray-bounds doesn't warn for pointer arithmetics?