Re: [PATCH] ACPI/IORT: Fix GCC 12 warning
From: Ard Biesheuvel <ardb@kernel.org>
Date: 2022-02-10 19:29:32
Also in:
linux-acpi, lkml
(cc Kees) On Thu, 10 Feb 2022 at 18:36, Victor Erminpour [off-list ref] wrote:
On 2/10/22 1:11 AM, Ard Biesheuvel wrote:quoted
On Thu, 10 Feb 2022 at 01:34, Victor Erminpour [off-list ref] wrote:quoted
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 <redacted>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/ (local) https://lore.kernel.org/linux-hardening/20211209043915.1378393-1-keescook@chromium.org/ (local)
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. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel