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++/94422] [9/10 Regression] static_cast from std::array operator[] to enum class
Date: Tue, 31 Mar 2020 10:24:07 +0000	[thread overview]
Message-ID: <bug-94422-4-bhpILFBGO3@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-94422-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94422

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[9 Regression] static_cast  |[9/10 Regression]
                   |from std::array operator[]  |static_cast from std::array
                   |to enum class               |operator[] to enum class
      Known to fail|                            |10.0

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Reduced:

// { dg-options "-std=gnu++17" }
template<typename T, unsigned N>
struct array
{
  T data[N];

  constexpr T& operator[](unsigned n) { return data[n]; }
};

enum class EnumC : signed char { Forward = 1, Backward = -1 };

array<unsigned char, sizeof(EnumC)> buf;

template <typename T>
struct S {
  void foo() { auto const cast_to_enum{static_cast<EnumC>(buf[0])}; }
};

S<int> s;

  parent reply	other threads:[~2020-03-31 10:24 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-31  9:41 [Bug c++/94422] New: static_cast from std::array " vincent.hamp at higaski dot at
2020-03-31 10:17 ` [Bug c++/94422] [9 Regression] static_cast from std::array operator[] " redi at gcc dot gnu.org
2020-03-31 10:24 ` redi at gcc dot gnu.org [this message]
2020-03-31 11:59 ` rguenth at gcc dot gnu.org
2020-03-31 16:23 ` jakub at gcc dot gnu.org
2021-06-01  8:17 ` rguenth at gcc dot gnu.org
2022-05-27  8:50 ` rguenth 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-94422-4-bhpILFBGO3@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).