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.
constant_of(^^v) for variable v of array type produces reflection of pointer constantSection: 21.4.7 [meta.reflection.queries] Status: New Submitter: Tomasz KamiĆski Opened: 2025-10-29 Last modified: 2025-10-31
Priority: Not Prioritized
View other active issues in [meta.reflection.queries].
View all other issues in [meta.reflection.queries].
View all issues with New status.
Discussion:
The unintended consequence of the late change of reflect_constant to accept its parameter by value
is that constant_of(a) returns a reflection of the value &a[0] for a variable of array type.
constant_of is specified as:
if constexpr (is_annotation(R)) {
return C;
} else {
return reflect_constant([: R :]);
}
In case when [: R :] is a reference to array, it will decay to a pointer to
the first element when accepted by value. I believe this is unintended and we should return an
reflection of an array object instead.
Proposed resolution:
This wording is relative to N5014.
Modify 21.4.7 [meta.reflection.queries] as indicated:
consteval info constant_of(info r);-6 Let
-7- Effects: Equivalent to:Rbe a constant expression of typeinfosuch thatR == ristrue. Ifrrepresents an annotation, then letCbe its underlying constant.if constexpr (is_annotation(R)) { return C; } else if constexpr (is_array_type(type_of(R))) { return reflect_constant_array([: R :]); } else { return reflect_constant([: R :]); }