public inbox for cgroups@vger.kernel.org
 help / color / mirror / Atom feed
From: Tejun Heo <tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
To: Jiri Slaby <jirislaby-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
Cc: 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
Date: Tue, 1 Nov 2022 06:46:35 -1000	[thread overview]
Message-ID: <Y2FNa4bGhJoevRKT@slm.duckdns.org> (raw)
In-Reply-To: <d833ad15-f458-d43d-cab7-de62ff54a939-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>

Hello,

On Tue, Nov 01, 2022 at 06:46:56AM +0100, Jiri Slaby wrote:
> Yes. The real problem is that using anything else then an INT_MIN <= x <=
> INT_MAX _constant_ in an enum is undefined in ANSI C < 2x (in particular, 1
> << x is undefined too). gcc manual defines unsigned int on the top of that
> as defined too (so this holds for our -std=g*).
> 
> > I suppose the most reasonable thing to do here is just splitting them into
> > separate enum definitions. Does anyone know how this behavior change came to
> > be?
> 
> C2x which introduces un/signed long enums. See the bug I linked in the
> commit log:
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=36113

I see. So, it was an extension but the new standard is defined differently
and we're gonna end up with that behavior.

> The change is also turned on in < C2x on purpose. AIUI, unless there is too
> much breakage. So we'd need to sort it out in (rather distant) future anyway
> (when we come up to -std=g2x).

The part that the new behavior applying to <C2x feels like an odd decision.
I'm having a hard time seeing the upsides in doing so but maybe that's just
me not knowing the area well enough.

> > Do we know whether clang is gonna be changed the same way?
> 
> In C2x, Likely. In < C2x, dunno what'd be the default.

It looks like we can do one of the following two:

* If gcc actually changes the behavior for <c2x, split the enums according
  to their sizes. This feels rather silly but I can't think of a better way
  to cater to divergent compiler behaviors.

* If gcc doesn't change the behavior for <c2x, there's nothing to do for the
  time being. Later when we switch to -std=g2x, we can just change the
  format strings to use the now larger types.

Does the above make sense?

Thanks.

-- 
tejun

  parent reply	other threads:[~2022-11-01 16:46 UTC|newest]

Thread overview: 15+ 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)
     [not found] ` <20221031114520.10518-1-jirislaby-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2022-10-31 12:24   ` Christoph Hellwig
2022-10-31 17:57     ` Tejun Heo
     [not found]       ` <Y2AMcSPAJpj6obSA-NiLfg/pYEd1N0TnZuCh8vA@public.gmane.org>
2022-11-01  5:46         ` Jiri Slaby
     [not found]           ` <d833ad15-f458-d43d-cab7-de62ff54a939-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2022-11-01 16:46             ` Tejun Heo [this message]
2022-11-02  8:35               ` David Laight
2022-11-02 16:27                 ` 'Tejun Heo'
     [not found]                   ` <Y2Kaghnu/sPvl0+g-NiLfg/pYEd1N0TnZuCh8vA@public.gmane.org>
2022-11-02 16:43                     ` 'Tejun Heo'
     [not found]                       ` <Y2KePvYRRMOrqzOe-NiLfg/pYEd1N0TnZuCh8vA@public.gmane.org>
2022-12-12 12:14                         ` Jiri Slaby
2022-12-12 21:46                           ` 'Tejun Heo'
2022-12-13  8:30                             ` David Laight
     [not found]                               ` <f5220f08bd7f45248d718f1919503261-1XygrNkDbNvwg4NCKwmqgw@public.gmane.org>
2022-12-13 11:15                                 ` Jiri Slaby
     [not found]                                   ` <9d2ead31-efab-cf49-08d4-1e613382d89f-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2022-12-13 11:50                                     ` David Laight
     [not found]                                       ` <542d413b9d044474a34b6e7a40d70541-1XygrNkDbNvwg4NCKwmqgw@public.gmane.org>
2022-12-13 12:05                                         ` Jiri Slaby
     [not found]                                           ` <c7539121-c8fc-b4b7-b722-ead833420b2b-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
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=Y2FNa4bGhJoevRKT@slm.duckdns.org \
    --to=tj-dgejt+ai2ygdnm+yrofe0a@public.gmane.org \
    --cc=axboe-tSWWG44O7X1aa/9Udqfwiw@public.gmane.org \
    --cc=cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=hch-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org \
    --cc=jirislaby-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=josef-DigfWCa+lFGyeJad7bwFQA@public.gmane.org \
    --cc=linux-block-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=mliska-AlSwsSmVLrQ@public.gmane.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox