On Fri, Mar 7, 2014 at 9:36 AM, Uros Bizjak <ubiz...@gmail.com> 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  <ubiz...@gmail.com>
>
>     * crtstuff.c (__JCR_LIST__): Declare as zero-length array.
>
> Bootstrapped and regression tested on x86_64-pc-linux-gnu {,-m32}.
>
> OK for mainline?
>
> Uros.
>
>
> Index: crtstuff.c
> ===================================================================
> --- crtstuff.c  (revision 208403)
> +++ crtstuff.c  (working copy)
> @@ -257,7 +257,7 @@ STATIC EH_FRAME_SECTION_CONST char __EH_FRAME_BEGI
>  #ifdef JCR_SECTION_NAME
>  /* Stick a label at the beginning of the java class registration info
>     so we can register them properly.  */
> -STATIC void *__JCR_LIST__[]
> +STATIC void *__JCR_LIST__[0]
>    __attribute__ ((used, section(JCR_SECTION_NAME), aligned(sizeof(void*))))
>    = { };
>  #endif /* JCR_SECTION_NAME */

I don't understand why this works.  You can't index element 0 of a 0
element array.

This code is relying on linker magic and it's not surprising that it
confuses the compiler.  Can you use a type cast or variable assignment
in frame_dummy instead?

Ian

Reply via email to