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

3648. format should not print bool with 'c'

Section: 22.14.2.2 [format.string.std] Status: WP Submitter: Zhihao Yuan Opened: 2021-11-30 Last modified: 2022-02-10

Priority: Not Prioritized

View other active issues in [format.string.std].

View all other issues in [format.string.std].

View all issues with WP status.

Discussion:

P1652R1 prints integral inputs as characters with 'c' and preserves the wording to treat bool as a one-byte unsigned integer; this accidentally asks the implementation to cast bool into a 1-bit character if a user asks for the 'c' presentation type.

Recent wording improvements made this implied behavior obvious.

[2021-12-04; Daniel comments]

This issue relates to LWG 3644.

[2022-01-30; Reflector poll]

Set status to Tentatively Ready after five votes in favour during reflector poll.

[2022-02-10 Approved at February 2022 virtual plenary. Status changed: Tentatively Ready → WP.]

Proposed resolution:

This wording is relative to N4901.

  1. Modify 22.14.2.2 [format.string.std], Table 67 [tab:format.type.bool], as indicated:

    Table 67 — Meaning of type options for bool [tab:format.type.bool]
    Type Meaning
    none, s Copies textual representation, either true or false, to the output.
    b, B, c, d, o, x, X As specified in Table 65 [tab:format.type.int] for the value static_cast<unsigned char>(value).