Re: [PATCH v2 4/5] uaccess: Disable -Wshadow in __scoped_user_access()

From: David Laight

Date: Tue Mar 03 2026 - 04:12:31 EST


On Mon, 2 Mar 2026 16:00:26 +0100
"Christophe Leroy (CS GROUP)" <chleroy@xxxxxxxxxx> wrote:

> Le 02/03/2026 à 14:27, david.laight.linux@xxxxxxxxx a écrit :
> > From: David Laight <david.laight.linux@xxxxxxxxx>
> >
> > -Wshadow is enabled by W=2 builds and __scoped_user_access() quite
> > deliberately creates a 'const' shadow of the 'user' address that
> > references a 'guard page' when the application passes a kernel pointer.
> >
> > Signed-off-by: David Laight <david.laight.linux@xxxxxxxxx>
>
> There is a problem with this patch:

(badly line-wrapped errors deleted)

It seems to need gcc 12.
(So Linus is in luck.)

Prior to gcc 12 the #pragma generated by _Pragma() act as the
controlled statement of the for () loop.

Trying to put the _Pragma() inside the for statement doesn't work at all.

David