Title
`from_chars` should not parse `"0b"` base prefixes
Status
wp
Section
[charconv.from.chars]
Submitter
Jan Schultke

Created on 2025-10-20.00:00:00 last changed 1 month ago

Messages

Date: 2025-11-11.10:48:55

Proposed resolution:

This wording is relative to N5014.

  1. Modify [charconv.from.chars] as indicated:

    constexpr from_chars_result from_chars(const char* first, const char* last,
                                           integer-type& value, int base = 10);
    

    -2- Preconditions: `base` has a value between 2 and 36 (inclusive).

    -3- Effects: The pattern is the expected form of the subject sequence in the "C" locale for the given nonzero base, as described for `strtol`, except that no `"0b"` or `"0B"` prefix shall appear if the value of `base` is 2, no `"0x"` or `"0X"` prefix shall appear if the value of `base` is 16, and except that `'-'` is the only sign that may appear, and only if `value` has a signed type.

    -4- Throws: Nothing.

Date: 2025-11-11.10:48:55

[ Kona 2025-11-08; Status changed: Immediate → WP. ]

Date: 2025-11-07.19:46:31

[ Kona 2025-11-07; approved by LWG. Status changed: New → Immediate. ]

Date: 2025-10-20.00:00:00

C23 added support for the `"0b"` and `"0B"` base prefix to `strtol`, and since the wording of `from_chars` for integers is based on `strol`, this inadvertently added support for parsing `"0b"` prefixes to `from_chars`.

History
Date User Action Args
2025-11-11 10:48:55adminsetmessages: + msg15685
2025-11-11 10:48:55adminsetstatus: immediate -> wp
2025-11-07 19:46:31adminsetmessages: + msg15599
2025-11-07 19:46:31adminsetstatus: new -> immediate
2025-10-25 13:26:44adminsetmessages: + msg15423
2025-10-20 00:00:00admincreate