[PATCH] add option to emit more array bounds warnigs
Jeff Law
law@redhat.com
Mon Jan 12 18:27:00 GMT 2015
On 11/11/14 23:13, Martin Uecker wrote:
>
> Hi,
>
> this proposed patch adds an option "-Warray-bounds=" in addition to
> "-Warray-bound". "-Warray-bounds=1" corresponds to "-Warray-bound".
> For higher warning levels more warnings about optional accesses
> outside of arrays are emitted. For example, warnings for
> arrays accessed through pointers are now emitted:
>
> void foo(int (*a)[3])
> {
> (*a)[4] = 1;
> }
>
> Also warnings for arrays which are the last element of a struct
> are emitted, if it is not a flexible array member or does not use
> the zero size extensions.
>
> Because there is the risk of false positives, the higher warning
> level is not used by default.
>
>
> Martin
>
>
> * gcc/tree-vrp.c (check_array_ref): Emit more warnings
> for warn_array_bounds >= 2.
> * gcc/testsuite/gcc.dg/Warray-bounds-11.c: New test-case.
> * gcc/c-family/c.opt: New option -Warray-bounds=.
> * gcc/common.opt: New option -Warray-bounds=.
> * gcc/doc/invoke.texi: Document new option.
Has this patch been bootstrapped and regression tested, if so on what
platform.
Given the new warnings (as implemented by the patch) are not enabled by
default, I'm inclined to approve once Martin verifies things via
bootstrap and regression test.
jeff
More information about the Gcc-patches
mailing list