public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Bit-field with std::byte as member type cannot be initialized: bug or feature?
@ 2019-11-29  9:18 Klaus Doldinger
  2019-11-29 11:37 ` Jonathan Wakely
  0 siblings, 1 reply; 3+ messages in thread
From: Klaus Doldinger @ 2019-11-29  9:18 UTC (permalink / raw)
  To: gcc-help

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

Thanks,
 Wilhelm

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

* Re: Bit-field with std::byte as member type cannot be initialized: bug or feature?
  2019-11-29  9:18 Bit-field with std::byte as member type cannot be initialized: bug or feature? Klaus Doldinger
@ 2019-11-29 11:37 ` Jonathan Wakely
  2019-11-29 17:44   ` Klaus Doldinger
  0 siblings, 1 reply; 3+ messages in thread
From: Jonathan Wakely @ 2019-11-29 11:37 UTC (permalink / raw)
  To: Klaus Doldinger; +Cc: gcc-help

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?

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

* Re: Bit-field with std::byte as member type cannot be initialized: bug or feature?
  2019-11-29 11:37 ` Jonathan Wakely
@ 2019-11-29 17:44   ` Klaus Doldinger
  0 siblings, 0 replies; 3+ messages in thread
From: Klaus Doldinger @ 2019-11-29 17:44 UTC (permalink / raw)
  To: gcc-help



Am 29.11.19 um 12:37 schrieb Jonathan Wakely:
> 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?
> 

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

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

end of thread, other threads:[~2019-11-29 17:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-29  9:18 Bit-field with std::byte as member type cannot be initialized: bug or feature? Klaus Doldinger
2019-11-29 11:37 ` Jonathan Wakely
2019-11-29 17:44   ` Klaus Doldinger

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