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

            Bug ID: 105061
           Summary: [9/10 Regression] [c++2a+] anonymous bitfield
                    templated offset rejected
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Keywords: rejects-valid
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: wjwray at gmail dot com
  Target Milestone: ---

A very specific regression: https://godbolt.org/z/dWxnvd93j

    template <typename alloc_unit, int width, int offset>
    struct offset_bitfield { alloc_unit : offset, field : width; };

 accepted forever  with -std=c++17-
 accepted in  9.4  with -std=c++2a
 rejected in 10.1+ with -std=c++20+
(accepted in Clang & MSVC, any std)

My guess as to the cause: the c++20 change to allow bitfield initializers.

    template <typename alloc_unit, int width, int offset>
    struct offset_bitfield { alloc_unit : offset, field : width; };
    //                                  ^       ^
    // error: found ':' in nested-name-specifier, expected '::'
    // error: expected unqualified-id before ',' token

The template is accepted if the typename parameter is removed:

    template <int width, int offset>
    struct uint_offset_bitfield { unsigned : offset, field : width; };

Reply via email to