[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <c7539121-c8fc-b4b7-b722-ead833420b2b@kernel.org>
Date: Tue, 13 Dec 2022 13:05:11 +0100
From: Jiri Slaby <jirislaby@...nel.org>
To: David Laight <David.Laight@...LAB.COM>, 'Tejun Heo' <tj@...nel.org>
Cc: Christoph Hellwig <hch@...radead.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
Martin Liska <mliska@...e.cz>,
Josef Bacik <josef@...icpanda.com>,
Jens Axboe <axboe@...nel.dk>,
"cgroups@...r.kernel.org" <cgroups@...r.kernel.org>,
"linux-block@...r.kernel.org" <linux-block@...r.kernel.org>
Subject: Re: [PATCH] block/blk-iocost (gcc13): cast enum members to int in
prints
On 13. 12. 22, 12:50, David Laight wrote:
> From: Jiri Slaby
>> Sent: 13 December 2022 11:15
>>
>> On 13. 12. 22, 9:30, David Laight wrote:
>>> From: Tejun Heo <htejun@...il.com> On Behalf Of 'Tejun Heo'
>>>> Sent: 12 December 2022 21:47
>>>> To: Jiri Slaby <jirislaby@...nel.org>
>>>> Cc: David Laight <David.Laight@...LAB.COM>; Christoph Hellwig <hch@...radead.org>; linux-
>>>> kernel@...r.kernel.org; Martin Liska <mliska@...e.cz>; Josef Bacik <josef@...icpanda.com>; Jens
>> Axboe
>>>> <axboe@...nel.dk>; cgroups@...r.kernel.org; linux-block@...r.kernel.org
>>>> Subject: Re: [PATCH] block/blk-iocost (gcc13): cast enum members to int in prints
>>>>
>>>> On Mon, Dec 12, 2022 at 01:14:31PM +0100, Jiri Slaby wrote:
>>>>>> If so, my suggestion is just sticking with the old behavior until we switch
>>>>>> to --std=g2x and then make one time adjustment at that point.
>>>>>
>>>>> So is the enum split OK under these circumstances?
>>>>
>>>> Oh man, it's kinda crazy that the compiler is changing in a way that the
>>>> same piece of code can't be compiled the same way across two adjoining
>>>> versions of the same compiler. But, yeah, if that's what gcc is gonna do and
>>>> splitting enums is the only way to be okay across the compiler versions,
>>>> there isn't any other choice we can make.
>>>
>>> It is also a silent code-breaker.
>>> Compile this for 32bit x86:
>>>
>>> enum { a = 1, b = ~0ull};
>>
>> But having ull in an enum is undefined anyway. C99 allows only int
>> constants. gnuC supports ulong expressions (IIRC).
>
> gcc supports 'long long' as well - 64bit on 32bit systems.
Can you elaborate what's source of this? Gcc manual says this about enum
values:
The integer type compatible with each enumerated type (C90 6.5.2.2, C99
and C11 6.7.2.2).
Normally, the type is unsigned int if there are no negative values in
the enumeration, otherwise int. If ‘-fshort-enums’ is specified, ...,
otherwise it is the first of unsigned char, unsigned short and unsigned
int that can represent all the values.
I.e. the documentation says uint is the highest possible enum value.
C2x/g2x also supports ulong (that's what it is all about). But we don't
do c2x quite yet.
thanks,
--
--
js
suse labs
Powered by blists - more mailing lists