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

Created on 2022-11-09.00:00:00 last changed 3 weeks ago

Messages

Date: 2022-11-11.21:14:29

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: 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
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