[Bug libstdc++/127219] <format>: make __valid_types_for_check_dynamic_spec static so check_dynamic_spec<Ts...> works with clang and EDG

cvs-commit at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Wed Sep 9 14:29:03 GMT 2026


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127219

--- Comment #6 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Tomasz Kaminski <tkaminsk@gcc.gnu.org>:

https://gcc.gnu.org/g:bb591391ec98a280bb706c20029bbeada87304d0

commit r17-4030-gbb591391ec98a280bb706c20029bbeada87304d0
Author: Steven Sudit <stevensudit@gmail.com>
Date:   Tue Sep 8 21:00:00 2026 -0400

    libstdc++: Make __valid_types_for_check_dynamic_spec static [PR127219]

    basic_format_parse_context::check_dynamic_spec<_Ts...> checks its
    template arguments with

      static_assert(__valid_types_for_check_dynamic_spec<_Ts...>(), ...);

    where __valid_types_for_check_dynamic_spec is a non-static consteval
    member, so the operand is an implicit member access on *this evaluated
    directly by the static_assert, not inside a call to a constexpr member
    function.  P2280R4 allows that use of this (the function never reads
    through it), and GCC and MSVC accept it, but Clang (through 23 and
    trunk, llvm/llvm-project#191104) and EDG 6.9 still reject the
    instantiation:

      error: static assertion expression is not an integral constant
        expression
      note: implicit use of 'this' pointer is only allowed within the
        evaluation of a call to a 'constexpr' member function

    so any user formatter that calls check_dynamic_spec<Ts...>(id) fails to
    compile with those front ends in C++26 mode.

    The function uses no non-static member, so declaring it static removes
    the this and changes nothing else.  std/format/parse_ctx.cc already
    instantiates check_dynamic_spec<Ts...>, which GCC accepts with either
    spelling.

    Assisted-by: Claude Fable 5.1 (Anthropic)

    libstdc++-v3/ChangeLog:

            PR libstdc++/127219
            * include/std/format
            (basic_format_parse_context::__valid_types_for_check_dynamic_spec):
            Make static, so that the static_assert in check_dynamic_spec does
            not use this.

    Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
    Signed-off-by: Steven Sudit <stevensudit@gmail.com>


More information about the Gcc-bugs mailing list