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

221. num_get<>::do_get stage 2 processing broken

Section: 30.4.3.2.3 [facet.num.get.virtuals] Status: CD1 Submitter: Matt Austern Opened: 2000-03-14 Last modified: 2016-01-28

Priority: Not Prioritized

View other active issues in [facet.num.get.virtuals].

View all other issues in [facet.num.get.virtuals].

View all issues with CD1 status.

Discussion:

Stage 2 processing of numeric conversion is broken.

Table 55 in 22.2.2.1.2 says that when basefield is 0 the integral conversion specifier is %i. A %i specifier determines a number's base by its prefix (0 for octal, 0x for hex), so the intention is clearly that a 0x prefix is allowed. Paragraph 8 in the same section, however, describes very precisely how characters are processed. (It must be done "as if" by a specified code fragment.) That description does not allow a 0x prefix to be recognized.

Very roughly, stage 2 processing reads a char_type ct. It converts ct to a char, not by using narrow but by looking it up in a translation table that was created by widening the string literal "0123456789abcdefABCDEF+-". The character "x" is not found in that table, so it can't be recognized by stage 2 processing.

Proposed resolution:

In 22.2.2.1.2 paragraph 8, replace the line:

static const char src[] = "0123456789abcdefABCDEF+-";

with the line:

static const char src[] = "0123456789abcdefxABCDEFX+-";

Rationale:

If we're using the technique of widening a string literal, the string literal must contain every character we wish to recognize. This technique has the consequence that alternate representations of digits will not be recognized. This design decision was made deliberately, with full knowledge of that limitation.