Issue 176767
Summary Clang rejects cv-qualified anonymous bit-fields (valid C++17)
Labels clang
Assignees
Reporter vrukesh
    What code / commands /steps will reproduce the problem?
Compile the sample code:

`
typedef int t;
typedef int q;

struct S {
  const    ::t : 1;
  volatile q   : 1;
};

int main(void) {}
`

**Compiler Explorer link:** https://godbolt.org/z/zhPWaq6qo

**What is the expected result?**
Compilation should pass

**What happens instead?**
g++ (GCC) compilation passes.
Clang rejects the unnamed bit-fields that carry cv-qualifiers.

C++17 [class.bit] says a bit-field is declared with a `decl-specifier-seq` (integral or enum type) and may omit the identifier; it forbids only reference types. No rule bans cv-qualifiers on an unnamed bit-field, so `const int : N;` and `volatile int : N;` are well-formed. The qualifiers are simply irrelevant because the field has no name, but the declaration is valid.


Clang’s rejection is nonconforming; the declarations should be accepted per the standard.

_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to