All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jiri Slaby <jirislaby@kernel.org>
To: David Laight <David.Laight@ACULAB.COM>, 'Tejun Heo' <tj@kernel.org>
Cc: Christoph Hellwig <hch@infradead.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Martin Liska <mliska@suse.cz>, Josef Bacik <josef@toxicpanda.com>,
	Jens Axboe <axboe@kernel.dk>,
	"cgroups@vger.kernel.org" <cgroups@vger.kernel.org>,
	"linux-block@vger.kernel.org" <linux-block@vger.kernel.org>
Subject: Re: [PATCH] block/blk-iocost (gcc13): cast enum members to int in prints
Date: Tue, 13 Dec 2022 13:05:11 +0100	[thread overview]
Message-ID: <c7539121-c8fc-b4b7-b722-ead833420b2b@kernel.org> (raw)
In-Reply-To: <542d413b9d044474a34b6e7a40d70541@AcuMS.aculab.com>

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@gmail.com> On Behalf Of 'Tejun Heo'
>>>> Sent: 12 December 2022 21:47
>>>> To: Jiri Slaby <jirislaby@kernel.org>
>>>> Cc: David Laight <David.Laight@ACULAB.COM>; Christoph Hellwig <hch@infradead.org>; linux-
>>>> kernel@vger.kernel.org; Martin Liska <mliska@suse.cz>; Josef Bacik <josef@toxicpanda.com>; Jens
>> Axboe
>>>> <axboe@kernel.dk>; cgroups@vger.kernel.org; linux-block@vger.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


WARNING: multiple messages have this Message-ID (diff)
From: Jiri Slaby <jirislaby-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
To: David Laight
	<David.Laight-ZS65k/vG3HxXrIkS9f7CXA@public.gmane.org>,
	'Tejun Heo' <tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
Cc: Christoph Hellwig <hch-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>,
	"linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
	<linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	Martin Liska <mliska-AlSwsSmVLrQ@public.gmane.org>,
	Josef Bacik <josef-DigfWCa+lFGyeJad7bwFQA@public.gmane.org>,
	Jens Axboe <axboe-tSWWG44O7X1aa/9Udqfwiw@public.gmane.org>,
	"cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
	<cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	"linux-block-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
	<linux-block-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Subject: Re: [PATCH] block/blk-iocost (gcc13): cast enum members to int in prints
Date: Tue, 13 Dec 2022 13:05:11 +0100	[thread overview]
Message-ID: <c7539121-c8fc-b4b7-b722-ead833420b2b@kernel.org> (raw)
In-Reply-To: <542d413b9d044474a34b6e7a40d70541-1XygrNkDbNvwg4NCKwmqgw@public.gmane.org>

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-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> On Behalf Of 'Tejun Heo'
>>>> Sent: 12 December 2022 21:47
>>>> To: Jiri Slaby <jirislaby-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
>>>> Cc: David Laight <David.Laight-ZS65k/vG3HxXrIkS9f7CXA@public.gmane.org>; Christoph Hellwig <hch-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>; linux-
>>>> kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org; Martin Liska <mliska-AlSwsSmVLrQ@public.gmane.org>; Josef Bacik <josef-DigfWCa+lFGyeJad7bwFQA@public.gmane.org>; Jens
>> Axboe
>>>> <axboe-tSWWG44O7X1aa/9Udqfwiw@public.gmane.org>; cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org; linux-block-u79uwXL29TY76Z2rM5mHXA@public.gmane.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


  reply	other threads:[~2022-12-13 12:05 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-31 11:45 [PATCH] block/blk-iocost (gcc13): cast enum members to int in prints Jiri Slaby (SUSE)
2022-10-31 11:45 ` Jiri Slaby (SUSE)
2022-10-31 12:24 ` Christoph Hellwig
2022-10-31 12:24   ` Christoph Hellwig
2022-10-31 17:57   ` Tejun Heo
2022-11-01  5:46     ` Jiri Slaby
2022-11-01  5:46       ` Jiri Slaby
2022-11-01 16:46       ` Tejun Heo
2022-11-01 16:46         ` Tejun Heo
2022-11-02  8:35         ` David Laight
2022-11-02 16:27           ` 'Tejun Heo'
2022-11-02 16:43             ` 'Tejun Heo'
2022-11-02 16:43               ` 'Tejun Heo'
2022-12-12 12:14               ` Jiri Slaby
2022-12-12 12:14                 ` Jiri Slaby
2022-12-12 21:46                 ` 'Tejun Heo'
2022-12-13  8:30                   ` David Laight
2022-12-13 11:15                     ` Jiri Slaby
2022-12-13 11:15                       ` Jiri Slaby
2022-12-13 11:50                       ` David Laight
2022-12-13 11:50                         ` David Laight
2022-12-13 12:05                         ` Jiri Slaby [this message]
2022-12-13 12:05                           ` Jiri Slaby
2022-12-13 12:58                           ` David Laight
2022-12-13 12:58                             ` David Laight

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c7539121-c8fc-b4b7-b722-ead833420b2b@kernel.org \
    --to=jirislaby@kernel.org \
    --cc=David.Laight@ACULAB.COM \
    --cc=axboe@kernel.dk \
    --cc=cgroups@vger.kernel.org \
    --cc=hch@infradead.org \
    --cc=josef@toxicpanda.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mliska@suse.cz \
    --cc=tj@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.