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

3828. Sync intmax_t and uintmax_t with C2x

Section: 17.4.1 [cstdint.syn] Status: C++23 Submitter: GB Opened: 2022-11-10 Last modified: 2023-11-22

Priority: Not Prioritized

View all other issues in [cstdint.syn].

View all issues with C++23 status.

Discussion:

This is the resolution for NB comment GB-080 17.4.1 [cstdint.syn] Sync intmax_t and uintmax_t with C2x.

With the approval of WG14 N2888 the next C standard will resolve the long-standing issue that implementations cannot support 128-bit integer types properly without ABI breaks. C++ should adopt the same fix now, rather than waiting until a future C++ standard is rebased on C2x.

31.13.2 [cinttypes.syn] also mentions those types, but doesn't need a change. The proposed change allows intmax_t to be an extended integer type of the same width as long long, in which case we'd still want those abs overloads.

Recommended change: Add to 31.13.2 [cinttypes.syn] p2 "except that intmax_t is not required to be able to represent all values of extended integer types wider than long long, and uintmax_t is not required to be able to represent all values of extended integer types wider than unsigned long long."

[Kona 2022-11-10; Waiting for LEWG electronic polling]

[2022-11; LEWG electronic polling]

Unanimous consensus in favor.

[Issaquah 2023-02-06; LWG]

Unanimous consent (13/0/0) to move to Immediate for C++23.

[2023-02-13 Approved at February 2023 meeting in Issaquah. Status changed: Immediate → WP.]

Proposed resolution:

This wording is relative to N4917.

  1. Modify 31.13.2 [cinttypes.syn] as indicated:

    -1- The contents and meaning of the header <cinttypes> are the same as the C standard library header <inttypes.h>, with the following changes:

    1. (1.1) — The header <cinttypes> includes the header <cstdint> instead of <stdint.h>, and

    2. (1.?) — intmax_t and uintmax_t are not required to be able to represent all values of extended integer types wider than long long and unsigned long long respectively, and

    3. (1.2) — if and only if the type intmax_t designates an extended integer type, the following function signatures are added:

      intmax_t abs(intmax_t);
      imaxdiv_t div(intmax_t, intmax_t);
      

      which shall have the same semantics as the function signatures intmax_t imaxabs(intmax_t) and imaxdiv_t imaxdiv(intmax_t, intmax_t), respectively.

    See also: ISO C 7.8