[PATCH gcc-16] libstdc++: Add constexpr to Debug Mode helpers for reflection vectors [PR124312]

Jonathan Wakely jwakely@redhat.com
Thu Oct 22 11:40:38 GMT 2026


On Thu, 22 Oct 2026 at 02:54, Mishmish Dev <mishmish@mishmish.dev> wrote:
> Use _GLIBCXX20_CONSTEXPR where a valid constant-evaluation path exists and
> _GLIBCXX23_CONSTEXPR for helpers that only run at runtime (attaching
> iterators, the error formatter).

Why?

If a valid constant-eval path exists, should they be constexpr on
trunk too? Do you have examples of code that exercises such paths?

If no constant-eval path exists and they're just being marked to make
reflection code able to use debug mode on gcc-16, wouldn't a new
_GLIBCXX26_CONSTEXPR macro make more sense? Or a new
_GLIBCXX_REFL_CONSTEXPR which is only defined when -freflection is
enabled?
It doesn't make much sense to mark them "constexpr for C++23 and
above" when they never need to be constexpr for C++23. Especially as
the use of those macros would diverge between gcc-16 and trunk, and
probably cause people to scratch their heads for the next few years
while gcc-16 is supported. If we have a specific macro that is
non-empty for -freflection then that can be clearly commented to
explain why it exists, and why it only exists on trunk.



More information about the Libstdc++ mailing list