public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "redi at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/98142] fstrict-enums optimization applied only for unscoped enums with unfixed underlying type
Date: Fri, 04 Dec 2020 15:03:15 +0000 [thread overview]
Message-ID: <bug-98142-4-ia6WY0IdzL@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-98142-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98142
--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Barry Revzin from comment #2)
> I guess in general this is kind of a scary optimization, since it doesn't
> seem like it's really a global thing? Perhaps this calls for an attribute?
>
> [[gnu::i_promise_on_penalty_of_ub_that_only_these_values_are_used]]
> enum class E : unsigned int { A, B, C, D };
>
> Or, you know, [[gnu::strict_enum]] or something.
It couldn't be called "strict_enum". The -fstrict-enums flag means assume no
invalid values, i.e. nothing outside the valid values of the enum type. For any
enum type with a fixed underlying type, all values of the underlying type are
valid values of the enum type, so there are no invalid values. So "strict_enum"
as the attribute name would be contradicting the meaning of -fstrict-enums.
So purely on that basis, the better name would be
"i_promise_on_penalty_of_ub_that_only_these_values_are_used"
next prev parent reply other threads:[~2020-12-04 15:03 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-04 13:54 [Bug c++/98142] New: " barry.revzin at gmail dot com
2020-12-04 13:59 ` [Bug c++/98142] " jakub at gcc dot gnu.org
2020-12-04 14:10 ` barry.revzin at gmail dot com
2020-12-04 14:13 ` jakub at gcc dot gnu.org
2020-12-04 15:03 ` redi at gcc dot gnu.org [this message]
2020-12-04 15:06 ` jakub at gcc dot gnu.org
2020-12-04 15:11 ` redi at gcc dot gnu.org
2020-12-04 15:12 ` redi at gcc dot gnu.org
2020-12-07 7:45 ` rguenth at gcc dot gnu.org
2020-12-07 10:32 ` redi at gcc dot gnu.org
2020-12-07 10:32 ` redi at gcc dot gnu.org
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=bug-98142-4-ia6WY0IdzL@http.gcc.gnu.org/bugzilla/ \
--to=gcc-bugzilla@gcc.gnu.org \
--cc=gcc-bugs@gcc.gnu.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).