This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of New status.
data_member_spec should throw for cv-qualified unnamed bit-fieldsSection: 21.4.16 [meta.reflection.define.aggregate] Status: New Submitter: Marek Polacek Opened: 2026-02-05 Last modified: 2026-02-09
Priority: Not Prioritized
View all other issues in [meta.reflection.define.aggregate].
View all issues with New status.
Discussion:
DR 2229 changed 11.4.10 [class.bit] p2 to say:
An unnamed bit-field shall not be declared with a cv-qualified type.
It follows that define_aggregate should have the same limitation, and thus in:
#include <meta>
constexpr auto d1 = std::meta::data_member_spec(^^const int, { .bit_width = 1 });
constexpr auto d2 = std::meta::data_member_spec(^^volatile int, { .bit_width = 1 });
constexpr auto d3 = std::meta::data_member_spec(^^const volatile int, { .bit_width = 1 });
all three data_member_spec should throw.
Proposed resolution:
This wording is relative to N5032.
Modify 21.4.16 [meta.reflection.define.aggregate] as indicated:
consteval info data_member_spec(info type, data_member_options options);-4- Returns: […]
-5- Throws:meta::exceptionunless the following conditions are met:
(5.1) —
dealias(type)represents either an object type or a reference type;(5.2) — if
options.namecontains a value, then: […](5.3) — if
options.namedoes not contain a value, thenoptions.bit_widthcontains a value;(5.4) — if
options.bit_widthcontains a valueV, then
(5.4.1) —
is_integral_type(type) || is_enum_type(type)istrue,(5.4.2) —
options.alignmentdoes not contain a value,(5.4.3) —
options.no_unique_addressisfalse,(5.4.4) —
Vis not negative, and(5.4.5) — if
Vequals0, thenoptions.namedoes not contain a value; and(5.4.?) — if
options.namedoes not contain a value, thenis_const(type) || is_volatile(type)isfalse; and(5.5) — if
options.alignmentcontains a value, it is an alignment value (6.8.3 [basic.align]) not less thanalignment_of(type).