|
| 1 | +<?xml version='1.0' encoding='utf-8' standalone='no'?> |
| 2 | +<!DOCTYPE issue SYSTEM "lwg-issue.dtd"> |
| 3 | + |
| 4 | +<issue num="4430" status="New"> |
| 5 | +<title>`from_chars` should not parse `"0b"` base prefixes</title> |
| 6 | +<section> |
| 7 | +<sref ref="[charconv.from.chars]"/> |
| 8 | +</section> |
| 9 | +<submitter>Jan Schultke</submitter> |
| 10 | +<date>20 Oct 2025</date> |
| 11 | +<priority>99</priority> |
| 12 | + |
| 13 | +<discussion> |
| 14 | +<p> |
| 15 | +C23 added support for the `"0b"` and `"0B"` base prefix to `strtol`, and since the wording of |
| 16 | +`from_chars` for integers is based on `strol`, this inadvertently added support for parsing |
| 17 | +`"0b"` prefixes to `from_chars`. |
| 18 | +</p> |
| 19 | +</discussion> |
| 20 | + |
| 21 | +<resolution> |
| 22 | +<p> |
| 23 | +This wording is relative to <paper num="N5014"/>. |
| 24 | +</p> |
| 25 | + |
| 26 | +<ol> |
| 27 | + |
| 28 | +<li><p>Modify <sref ref="[charconv.from.chars]"/> as indicated:</p> |
| 29 | + |
| 30 | +<blockquote> |
| 31 | +<pre> |
| 32 | +constexpr from_chars_result from_chars(const char* first, const char* last, |
| 33 | + <i>integer-type</i>& value, int base = 10); |
| 34 | +</pre> |
| 35 | +<blockquote> |
| 36 | +<p> |
| 37 | +-2- <i>Preconditions</i>: `base` has a value between 2 and 36 (inclusive). |
| 38 | +<p/> |
| 39 | +-3- <i>Effects</i>: The pattern is the expected form of the subject sequence in the "C" locale for |
| 40 | +the given nonzero base, as described for `strtol`, except that no <ins>`"0b"` or `"0B"` prefix |
| 41 | +shall appear if the value is `base` 2, no</ins> `"0x"` or `"0X"` prefix shall appear if the value |
| 42 | +of `base` is 16, and except that `'-'` is the only sign that may appear, and only if `value` has |
| 43 | +a signed type. |
| 44 | +<p/> |
| 45 | +-4- <i>Throws</i>: Nothing. |
| 46 | +</p> |
| 47 | +</blockquote> |
| 48 | +</blockquote> |
| 49 | +</li> |
| 50 | +</ol> |
| 51 | + |
| 52 | +</resolution> |
| 53 | + |
| 54 | +</issue> |
0 commit comments