Created on 2025-10-29.00:00:00 last changed 1 week ago
Proposed resolution:
This wording is relative to N5014.
Modify [meta.reflection.queries] as indicated:
consteval info constant_of(info r);-6 Let R be a constant expression of type `info` such that R == r is `true`. If `r` represents an annotation, then let C be its underlying constant.
-7- Effects: Equivalent to: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 :]); }
[ 2025-11-11; Resolved by CWG 3111, approved in Kona. Status changed: New → Resolved. ]
[ Kona 2025-11-07; Will be resolved by CWG 3111. ]
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.
For reference, `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.
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2025-11-11 12:45:27 | admin | set | messages: + msg15714 |
| 2025-11-11 12:45:27 | admin | set | status: new -> resolved |
| 2025-11-07 19:19:35 | admin | set | messages: + msg15594 |
| 2025-10-31 11:11:35 | admin | set | messages: + msg15475 |
| 2025-10-29 00:00:00 | admin | create | |