[PATCH] include more detail in -Warray-bounds (PR 86650)

Martin Sebor msebor@gmail.com
Mon Jul 23 23:49:00 GMT 2018


(David, I'm hoping your your help here.  Please see the end.)

While looking into a recent -Warray-bounds instance in Glibc
involving inlining of large functions it became apparent that
GCC could do a better job of pinpointing the source of
the problem.

The attached patch makes a few adjustments to both
the pretty printer infrastructure and to VRP to make this
possible.  The diagnostic pretty printer already has directives
to print the inlining context for both tree and gcall* arguments,
so most of the changes just adjust things to be able to pass in
gimple* argument instead.

The only slightly interesting change is to print the declaration
to which the out-of-bounds array refers if one is known.

Tested on x86_64-linux with one regression.

The regression is in the gcc.dg/Warray-bounds.c test: the column
numbers of the warnings are off.  Adding the %G specifier to
the array bounds warnings in VRP has the unexpected effect of
expanding the extent of the underling. For instance, for a test
case like this:

   int a[10];

   void f (void)
   {
     a[-1] = 0;
   }

from the expected:

    a[-1] = 0;
    ~^~~~

to this:

   a[-1] = 0;
    ~~~~~~^~~

David, do you have any idea how to avoid this?

Martin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: gcc-86650.diff
Type: text/x-patch
Size: 35438 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20180723/e8631655/attachment.bin>


More information about the Gcc-patches mailing list