C++ Logo

STD-DISCUSSION

Advanced search

Subject: Re: bit field: is enum A : 1 valid syntax?
From: Stephan Bergmann (sbergman_at_[hidden])
Date: 2021-05-21 01:20:58


On 20/05/2021 23:47, Eric Suen via Std-Discussion wrote:
> I'm writing a cpp parse, constant-expression is conflict with enum-base
> or class base-clause, do I need look ahead and check?
>
> enum A {
> };
>
> struct S {
>   enum A :1;
>   enum A a:1;
> };
>
> gcc accept both, clang and vs only accept 2nd

[dcl.enum]/1: "A : following 'enum nested-name-specifier_opt identifier'
within the decl-specifier-seq of a member-declaration is parsed as part
of an enum-base."


STD-DISCUSSION list run by std-discussion-owner@lists.isocpp.org

Older Archives on Google Groups