This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH, libgcc]: Avoid warning: array subscript is above array bounds when compiling crtstuff.c
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Richard Biener <richard dot guenther at gmail dot com>
- Cc: Uros Bizjak <ubizjak at gmail dot com>, Ian Lance Taylor <iant at google dot com>, "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>
- Date: Tue, 11 Mar 2014 12:02:03 +0100
- Subject: Re: [PATCH, libgcc]: Avoid warning: array subscript is above array bounds when compiling crtstuff.c
- Authentication-results: sourceware.org; auth=none
- References: <CAFULd4awVFMCqOP48Sq_1mqWOKZky1RvfGAsAHjhQONzM=4FAg at mail dot gmail dot com> <CAKOQZ8w3K_zaKtPuPZz=Jn4TTP2BbFrroKQYkn3ZDO6Z8yoqPA at mail dot gmail dot com> <CAFULd4Y6p0kCyyE3nEnOFTmWhv785++E4dOh=HWZfX+sjFKkCQ at mail dot gmail dot com> <CAKOQZ8y9KVPSKt+MjrL-YVoq+ZJr93ag7T=E-ZJorKPJ=HYu1g at mail dot gmail dot com> <20140309173142 dot GP22862 at tucnak dot redhat dot com> <CAFULd4apzqyXy+t8uGt=rwR+rQGYxrVDY+-UVWc+wa-3iw3fcw at mail dot gmail dot com> <20140310074932 dot GQ22862 at tucnak dot redhat dot com> <CAFULd4a+pxpUGT8EPv0ZjRO2CROPGiRJ53LM1pFdvtc1h98nBw at mail dot gmail dot com> <20140310101419 dot GS22862 at tucnak dot redhat dot com> <CAFiYyc1+8_wvoiVcM-az0Z3R_CQyciAab8TOnrsjdjR8=oUG8Q at mail dot gmail dot com>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Tue, Mar 11, 2014 at 11:58:01AM +0100, Richard Biener wrote:
> On Mon, Mar 10, 2014 at 11:14 AM, Jakub Jelinek <jakub@redhat.com> wrote:
> > On Mon, Mar 10, 2014 at 11:10:05AM +0100, Uros Bizjak wrote:
> >> > Well, better is non-obvious, while it is smaller (which is good for
> >> > initialization and thus rarely executed code), the common case is that
> >> > *jcr_list is 0 (gcj is used rarely these days) and for the common case it is
> >> > one instruction longer.
> >> > Perhaps at least use if (__builtin_expect (*jcr_list != NULL, 0))?
> >> > Otherwise looks good to me.
> >>
> >> Following source:
> >>
> >> void frame_dummy (void)
> >> {
> >> void **jcr_list = __JCR_LIST__;
> >> if (__builtin_expect (*jcr_list != 0, 0))
> >> register_classes (jcr_list);
> >> }
> >>
> >> generates exactly the same code while avoiding the warning. So,
> >> following your concern, I am testing following patch:
> >
> > But then the asm is gone and it can start to break any time soon.
> > For GCC __JCR_LIST__ is simply a zero sized local array and thus
> > dereferencing it's first element is invalid. It doesn't know that we use
> > linker magic to populate the array.
>
> You can also declare it extern and define the symbol in a global asm ...
But then you need to know how (which is quite target dependent).
Or define it in some other CU and ld -r it together, but supposedly not all
linkers can do ld -r.
Jakub
- References:
- [PATCH, libgcc]: Avoid warning: array subscript is above array bounds when compiling crtstuff.c
- Re: [PATCH, libgcc]: Avoid warning: array subscript is above array bounds when compiling crtstuff.c
- Re: [PATCH, libgcc]: Avoid warning: array subscript is above array bounds when compiling crtstuff.c
- Re: [PATCH, libgcc]: Avoid warning: array subscript is above array bounds when compiling crtstuff.c
- Re: [PATCH, libgcc]: Avoid warning: array subscript is above array bounds when compiling crtstuff.c
- Re: [PATCH, libgcc]: Avoid warning: array subscript is above array bounds when compiling crtstuff.c
- Re: [PATCH, libgcc]: Avoid warning: array subscript is above array bounds when compiling crtstuff.c
- Re: [PATCH, libgcc]: Avoid warning: array subscript is above array bounds when compiling crtstuff.c
- Re: [PATCH, libgcc]: Avoid warning: array subscript is above array bounds when compiling crtstuff.c
- Re: [PATCH, libgcc]: Avoid warning: array subscript is above array bounds when compiling crtstuff.c