gcc-12: build errors: arch/arm64/kernel/setup.c:225:56: warning: array subscript -1 is outside array bounds of 'char[]' [-Warray-bounds]

Maxime Ripard maxime at cerno.tech
Mon Jun 6 02:01:29 PDT 2022


Hi,

On Fri, Jun 03, 2022 at 09:40:07AM +0200, Arnd Bergmann wrote:
> On Fri, Jun 3, 2022 at 4:03 AM Naresh Kamboju <naresh.kamboju at linaro.org> wrote:
> >     inlined from 'setup_arch' at arch/arm64/kernel/setup.c:350:2:
> > arch/arm64/kernel/setup.c:225:56: warning: array subscript -1 is
> > outside array bounds of 'char[]' [-Warray-bounds]
> >   225 |         kernel_code.end     = __pa_symbol(__init_begin - 1);
> >
> 
> Is this the only warning of this type that you get for arm64?

In that function, both kernel_code.end and kernel_data_end show a
similar warning in 5.19-rc1

> I think the easy fix would be to reword this line to
> 
>        kernel_code.end     = __pa_symbol(__init_begin) - 1;

Doing this for both fix the warnings.

Maxime
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 228 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20220606/bab73868/attachment.sig>


More information about the linux-arm-kernel mailing list