[PATCH gcc-16] libstdc++: Add constexpr to Debug Mode helpers for reflection vectors [PR124312]
Mishmish Dev
mishmish@mishmish.dev
Thu Oct 22 16:19:54 GMT 2026
On Thu, 22 Oct 2026 at 11:35, Jonathan Wakely <jwakely@redhat.com> wrote:
> Why does reflection need additional functions and types to be
> instantiated which are not needed for non-reflection constant
> expressions?
[...]
> Is it just that every member function of a consteval-only type must be
> constexpr, even the ones that are never actually constant evaluated?
Yes. On gcc-16, a non-constexpr function of consteval-only type is
rejected when it is instantiated, even if it is never evaluated. A
constexpr one escalates to immediate instead. Example without
_GLIBCXX_DEBUG: https://godbolt.org/z/3E631n6vY
> I think a better solution would be for reflection to always use the
> non-debug vector.
That needs a front-end change too: the metafunction results are built
by looking up std::vector (get_vector_info in cp/reflect.cc), which
finds __debug::vector, so with only the <meta> change even
"auto v = std::meta::nonstatic_data_members_of(...)" is rejected. It
would also require users to spell out a different type, which IMO
creates more complexity and confusion.
I'll send a v2 using a reflection-only _GLIBCXX_REFLECTION_CONSTEXPR,
so non-reflection code is unchanged.
--
Mishmish
More information about the Libstdc++
mailing list