Title
Missing compile-time argument id check in basic_format_parse_context::next_arg_id
Status
c++23
Section
[format.parse.ctx]
Submitter
Victor Zverovich

Created on 2022-11-09.00:00:00 last changed 5 months ago

Messages

Date: 2023-02-13.10:17:57

Proposed resolution:

This wording is relative to N4917.

  1. Modify [format.parse.ctx] as indicated:

    constexpr size_t next_arg_id();
    

    -7- Effects: If indexing_ != manual is true, equivalent to:

    if (indexing_ == unknown)
      indexing_ = automatic;
    return next_arg_id_++;
    

    -8- Throws: format_error if indexing_ == manual is true which indicates mixing of automatic and manual argument indexing.

    -?- Remarks: Let cur-arg-id be the value of next_arg_id_ prior to this call. Call expressions where cur-arg-id >= num_args_ is true are not core constant expressions ([expr.const]).

    constexpr size_t check_arg_id(size_t id);
    

    -9- Effects: If indexing_ != automatic is true, equivalent to:

    if (indexing_ == unknown)
      indexing_ = manual;
    

    -10- Throws: format_error if indexing_ == automatic is true which indicates mixing of automatic and manual argument indexing.

    -11- Remarks: Call expressions where id >= num_args_ is true are not core constant expressions ([expr.const]).

Date: 2023-02-13.00:00:00

[ 2023-02-13 Approved at February 2023 meeting in Issaquah. Status changed: Voting → WP. ]

Date: 2022-11-11.21:14:29

[ Kona 2022-11-11; move to Ready ]

Date: 2022-11-15.00:00:00

[ 2022-11-11; Tomasz provide improved wording; Move to Open ]

Clarify that the value of next_arg_id_ is used, and add missing "is true."

Date: 2022-11-11.21:14:29

The definition of check_arg_id in [format.parse.ctx] includes a (compile-time) argument id check in the Remarks element:

constexpr void check_arg_id(size_t id);

[…]

Remarks: Call expressions where id >= num_args_ are not core constant expressions ([expr.const]).

However, a similar check is missing from next_arg_id which means that there is no argument id validation in user-defined format specification parsing code that invokes this function (e.g. when parsing automatically indexed dynamic width).

Previous resolution [SUPERSEDED]:

This wording is relative to N4917.

  1. Modify [format.parse.ctx] as indicated:

    constexpr size_t next_arg_id();
    

    -7- Effects: If indexing_ != manual, equivalent to:

    if (indexing_ == unknown)
      indexing_ = automatic;
    return next_arg_id_++;
    

    -8- Throws: format_error if indexing_ == manual which indicates mixing of automatic and manual argument indexing.

    -?- Remarks: Call expressions where next_arg_id_ >= num_args_ are not core constant expressions ([expr.const]).

History
Date User Action Args
2023-11-22 15:47:43adminsetstatus: wp -> c++23
2023-02-13 10:17:57adminsetmessages: + msg13363
2023-02-13 10:17:57adminsetstatus: voting -> wp
2023-02-06 15:33:48adminsetstatus: ready -> voting
2022-11-11 21:14:29adminsetmessages: + msg13027
2022-11-11 21:14:29adminsetmessages: + msg13026
2022-11-11 21:14:29adminsetstatus: open -> ready
2022-11-11 12:47:05adminsetstatus: new -> open
2022-11-09 16:27:45adminsetmessages: + msg12979
2022-11-09 00:00:00admincreate