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;