RE: [PATCH] workqueue: fix enum type for gcc-13

From: David Laight
Date: Thu Jan 19 2023 - 04:21:16 EST


From: Tejun Heo
> Sent: 19 January 2023 01:42
>
> On Wed, Jan 18, 2023 at 09:32:45PM +0100, Arnd Bergmann wrote:
> > the enum type has to be compatible with 'long long' because
> > anything shorter would not fit both -1 and -1u (UINT_MAX).
> > A and B were both signed types to match the signedness of the
> > enum type, but A was actually a 32-bit integer since that is
> > sufficient, while B was also a 64-bit type since it exceeds
> > INT_MAX. Now they are both the same type.
>
> Yeah, the new behavior makes total sense.
>
> > I don't think there is a chance they will revert to the old behavior,
> > though we could try asking for an command line flag to warn about
> > cases where this changes code generation.
>
> but the way that it's transitioning doesn't really make sense to me. We do
> phase out support for old compilers, so it isn't that difficult to manage
> this transition smoothly - add a compat option in the new versions, switch
> code later once old compilers are phased out and drop the compat flag.
>
> The way it's currently done causes situations which can't be handled
> logically - we end up having to regroup enums based on their value range
> rather than the logical type they need to be because there's no way to
> override the enum type on older compilers.

Didn't someone say that either C++ or C23 defines a syntax to explicitly
set the type of the enum.
IIRC gcc-13 doesn't support that.

If gcc-13 supported explicit setting of the type and also generated a
warn/error enum with 'large' values when the type wasn't specified
(ie where the gcc extension had been used) then at least there would
be no obscure surprises.
Getting an old gcc to ignore the type is easy.

David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)