[PATCH] ACPI/IORT: Fix GCC 12 warning
Ard Biesheuvel
ardb at kernel.org
Thu Feb 10 11:39:39 PST 2022
On Thu, 10 Feb 2022 at 20:29, Ard Biesheuvel <ardb at kernel.org> wrote:
>
> (cc Kees)
>
... for real this time :-)
> On Thu, 10 Feb 2022 at 18:36, Victor Erminpour
> <victor.erminpour at oracle.com> wrote:
> >
> >
> > On 2/10/22 1:11 AM, Ard Biesheuvel wrote:
> > > On Thu, 10 Feb 2022 at 01:34, Victor Erminpour
> > > <victor.erminpour at oracle.com> wrote:
> > >> When building with automatic stack variable initialization, GCC 12
> > >> complains about variables defined outside of switch case statements.
> > >> Move the variable into the case that uses it, which silences the warning:
> > >>
> > >> ./drivers/acpi/arm64/iort.c:1670:59: error: statement will never be executed [-Werror=switch-unreachable]
> > >> 1670 | struct acpi_iort_named_component *ncomp;
> > >> | ^~~~~
> > >>
> > >> Signed-off-by: Victor Erminpour <victor.erminpour at oracle.com>
> > > GCC 12 is not released yet, and this is clearly a compiler bug (a
> > > declaration is not a statement, and the hidden offending statement
> > > [the zero-init] is emitted by the compiler itself), so please report
> > > this to the GCC folks instead.
> >
> > Hi Ard,
> >
> > Thanks for the reply.
> > This fix is similar to the following commits that have been integrated
> > upstream:
> > https://lore.kernel.org/linux-hardening/20211209043456.1377875-1-keescook@chromium.org/
> > https://lore.kernel.org/linux-hardening/20211209043915.1378393-1-keescook@chromium.org/
> >
>
> If GCC 12 rejects valid C with this feature enabled, the compiler is
> broken and needs to be fixed. Papering over this by making changes to
> perfectly valid C code is a slippery slope that we should avoid.
>
> Since GCC 12 is not released yet, there is time to get this fixed properly.
>
> > You're not obligated to integrate this commit,
>
> Why, thank you :-)
>
> > but you may run into this
> > issue once
> > upstream starts using GCC 12 (or a patched version of GCC 11 in my case)
> > with the
> > CONFIG_INIT_STACK_ALL_ZERO option enabled.
> >
>
> Yes, that part was perfectly clear.
More information about the linux-arm-kernel
mailing list