Bit-field with std::byte as member type cannot be initialized: bug or feature?
Jonathan Wakely
jwakely.gcc@gmail.com
Fri Nov 29 11:37:00 GMT 2019
On Fri, 29 Nov 2019 at 09:18, Klaus Doldinger
<klaus.doldinger64@gmail.com> wrote:
>
> In C++20 bit-field initializer are possible. But this feature seems
> impossible to use with std::byte.
>
> struct Test {
> std::byte a : 2 = std::byte{0}; // NOK
> uint8_t b : 2 = 0; // OK
> };
>
> Is this intentional or a bug in g++-10 (the version I'm using).
It's a bug (and obviously applies to any scoped enumeration, not just
std::byte).
enum class byte : unsigned char { };
using uint8_t = unsigned char;
struct Test
{
byte a : 2 = byte{0}; // NOK
uint8_t b : 2 = 0; // OK
};
I assume it simply hasn't been implemented yet. Could you please
report it to bugzilla?
More information about the Gcc-help
mailing list