This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of Ready status.

### 3825. Missing compile-time argument `id` check in `basic_format_parse_context::next_arg_id`

Section: 22.14.6.5 [format.parse.ctx] Status: Ready Submitter: Victor Zverovich Opened: 2022-11-09 Last modified: 2022-11-11

Priority: Not Prioritized

View all issues with Ready status.

Discussion:

The definition of `check_arg_id` in 22.14.6.5 [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 (7.7 [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 22.14.6.5 [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 (7.7 [expr.const]).

[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`."

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

Proposed resolution:

This wording is relative to N4917.

1. Modify 22.14.6.5 [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 (7.7 [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 (7.7 [expr.const]).