public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/94422] New: static_cast from std::array to enum class
@ 2020-03-31  9:41 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
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: vincent.hamp at higaski dot at @ 2020-03-31  9:41 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 94422
           Summary: static_cast from std::array to enum class
           Product: gcc
           Version: 9.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: vincent.hamp at higaski dot at
  Target Milestone: ---

static_cast from std::array operator[] to an enum class inside a template class
produces an unexpected expression error. It seems that error is only present in
9.3, 9.2 and trunk work.

#include <array>
#include <cstdint>

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

std::array<uint8_t, sizeof(EnumC)> buf;

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

S<int> s;

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug c++/94422] [9 Regression] static_cast from std::array operator[] to enum class
  2020-03-31  9:41 [Bug c++/94422] New: static_cast from std::array to enum class vincent.hamp at higaski dot at
@ 2020-03-31 10:17 ` redi at gcc dot gnu.org
  2020-03-31 10:24 ` [Bug c++/94422] [9/10 " redi at gcc dot gnu.org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: redi at gcc dot gnu.org @ 2020-03-31 10:17 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |ice-on-valid-code
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2020-03-31
      Known to work|                            |9.2.0
            Summary|static_cast from std::array |[9 Regression] static_cast
                   |operator[] to enum class    |from std::array operator[]
                   |                            |to enum class
      Known to fail|                            |9.3.0
             Status|UNCONFIRMED                 |NEW

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
You didn't say what gcc options you're using, and since this only happens with
C++17 or C++20 (not the default options) that's not very helpful.

Confirmed for -std=gnu++17

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug c++/94422] [9/10 Regression] static_cast from std::array operator[] to enum class
  2020-03-31  9:41 [Bug c++/94422] New: static_cast from std::array to enum class 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
  2020-03-31 11:59 ` [Bug c++/94422] [9 " rguenth at gcc dot gnu.org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: redi at gcc dot gnu.org @ 2020-03-31 10:24 UTC (permalink / raw)
  To: gcc-bugs

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;

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug c++/94422] [9 Regression] static_cast from std::array operator[] to enum class
  2020-03-31  9:41 [Bug c++/94422] New: static_cast from std::array to enum class 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 ` [Bug c++/94422] [9/10 " redi at gcc dot gnu.org
@ 2020-03-31 11:59 ` rguenth at gcc dot gnu.org
  2020-03-31 16:23 ` jakub at gcc dot gnu.org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu.org @ 2020-03-31 11:59 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |9.4
           Priority|P3                          |P2

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug c++/94422] [9 Regression] static_cast from std::array operator[] to enum class
  2020-03-31  9:41 [Bug c++/94422] New: static_cast from std::array to enum class vincent.hamp at higaski dot at
                   ` (2 preceding siblings ...)
  2020-03-31 11:59 ` [Bug c++/94422] [9 " 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
  5 siblings, 0 replies; 7+ messages in thread
From: jakub at gcc dot gnu.org @ 2020-03-31 16:23 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org,
                   |                            |jason at gcc dot gnu.org

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Started with r9-8323-gb4e53e9b3c963b1c0fe9637618dec8042764f599

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug c++/94422] [9 Regression] static_cast from std::array operator[] to enum class
  2020-03-31  9:41 [Bug c++/94422] New: static_cast from std::array to enum class vincent.hamp at higaski dot at
                   ` (3 preceding siblings ...)
  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
  5 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-06-01  8:17 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|9.4                         |9.5

--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 9.4 is being released, retargeting bugs to GCC 9.5.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug c++/94422] [9 Regression] static_cast from std::array operator[] to enum class
  2020-03-31  9:41 [Bug c++/94422] New: static_cast from std::array to enum class vincent.hamp at higaski dot at
                   ` (4 preceding siblings ...)
  2021-06-01  8:17 ` rguenth at gcc dot gnu.org
@ 2022-05-27  8:50 ` rguenth at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-05-27  8:50 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED
   Target Milestone|9.5                         |10.0

--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> ---
Fixed in GCC 10.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-05-27  8:50 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-31  9:41 [Bug c++/94422] New: static_cast from std::array to enum class 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 ` [Bug c++/94422] [9/10 " redi at gcc dot gnu.org
2020-03-31 11:59 ` [Bug c++/94422] [9 " 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

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).