Bug 115776 - [C++26] Implement P2757R3 Type checking format args
Summary: [C++26] Implement P2757R3 Type checking format args
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: libstdc++ (show other bugs)
Version: 15.0
: P3 normal
Target Milestone: 15.0
Assignee: Jonathan Wakely
URL: https://gcc.gnu.org/pipermail/gcc-pat...
Keywords: patch
Depends on:
Blocks: c++26-lib
  Show dependency treegraph
 
Reported: 2024-07-03 20:25 UTC by Jonathan Wakely
Modified: 2024-07-31 18:39 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2024-07-03 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jonathan Wakely 2024-07-03 20:25:17 UTC
https://wg21.link/p2757r3
Comment 1 Jonathan Wakely 2024-07-16 12:11:25 UTC
Patch posted: https://gcc.gnu.org/pipermail/gcc-patches/2024-July/657390.html
Comment 2 GCC Commits 2024-07-31 16:08:12 UTC
The master branch has been updated by Jonathan Wakely <redi@gcc.gnu.org>:

https://gcc.gnu.org/g:3836df7e895beda1f159620bfd20024136fda9f0

commit r15-2446-g3836df7e895beda1f159620bfd20024136fda9f0
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Tue Jul 9 12:12:56 2024 +0100

    libstdc++: Implement C++26 type checking for std::format args [PR115776]
    
    Implement the changes from P2757R3, which enhance the parse context to
    be able to do type checking on format arguments, and to use that to
    ensure that args used for width and precisions are integral types.
    
    libstdc++-v3/ChangeLog:
    
            PR libstdc++/115776
            * include/bits/version.def (format): Update for C++26.
            * include/bits/version.h: Regenerate.
            * include/std/format (basic_format_parse_context): Remove
            default argument from constructor and split into two
            constructors. Make the constructor taking size_t private for
            C++26 and later.
            (basic_format_parse_context::check_dynamic_spec): New member
            function template.
            (basic_format_parse_context::check_dynamic_spec_integral): New
            member function.
            (basic_format_parse_context::check_dynamic_spec_string):
            Likewise.
            (__format::_Spec::_S_parse_width_or_precision): Use
            check_dynamic_spec_integral.
            (__format::__to_arg_t_enum): New helper function.
            (basic_format_arg):  Declare __to_arg_t_enum as friend.
            (__format::_Scanner): Define and use a derived parse context
            type.
            (__format::_Checking_scanner): Make arg types available to parse
            context.
            * testsuite/std/format/functions/format.cc: Check for new values
            of __cpp_lib_format macro.
            * testsuite/std/format/parse_ctx.cc: Check all members of
            basic_format_parse_context.
            * testsuite/std/format/parse_ctx_neg.cc: New test.
            * testsuite/std/format/string.cc: Add more checks for dynamic
            width and precision args.
Comment 3 Jonathan Wakely 2024-07-31 18:39:09 UTC
Implemented for GCC 15