[PATCH, libgcc]: Avoid warning: array subscript is above array bounds when compiling crtstuff.c

Jakub Jelinek jakub@redhat.com
Sun Mar 9 19:15:00 GMT 2014


On Sun, Mar 09, 2014 at 09:41:59AM -0700, Ian Lance Taylor wrote:
> >>> Attached patch avoids a bunch of:
> >>>
> >>> ../../../gcc-svn/trunk/libgcc/crtstuff.c: In function 'frame_dummy':
> >>> ../../../gcc-svn/trunk/libgcc/crtstuff.c:463:19: warning: array
> >>> subscript is above array bounds [-Warray-bounds]
> >>>    if (__JCR_LIST__[0])
> >>>                    ^
> >>>
> >>> when compiling libgcc.
> >>>
> >>> 2014-03-08  Uros Bizjak  <ubizjak@gmail.com>
> >>>
> >>>     * crtstuff.c (__JCR_LIST__): Declare as zero-length array.

I guess the only thing to avoid the warning (and potential miscompilation)
is to hide the access from the optimizers through something like:
  void *jcr_list;
  __asm ("" : "=g" (jcr_list) : "0" (__JCR_LIST__));
and then use jcr_list instead of __JCR_LIST__.

	Jakub



More information about the Gcc-patches mailing list