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

3696. "Basic integral types" should not be used

Section: 31.2.2 [stream.types] Status: New Submitter: Jiang An Opened: 2022-05-07 Last modified: 2025-06-16

Priority: 3

View all issues with New status.

Discussion:

Raised from editorial issue #5240.

The phrase "signed basic integral types" in 31.2.2 [stream.types] has been present since C++98 but never defined. It is unclear whether "basic integral types" are "standard integer types" or "integer types" (including extended integer types).

As std::streamoff should be wide enough to represent the largest possible file size, and std::uintmax_t is used as the return type of std::filesystem::file_size, we should not disallow std::streamoff to be an extended integer type which may be wider than long long. On the other hand, as std::size_t and std::ptrdiff_t have already been allowed to be extended integer types, std::streamsize should also be allowed to be an extended integer type for consistency.

So I think we should just use "signed integer types" instead of "signed basic integral types" in 31.2.2 [stream.types].

[2022-05-17; Reflector poll]

Set priority to 3 after reflector poll.

[2025-06-16; Jonathan adds wording]

Proposed resolution:

This wording is relative to N5008.

  1. Modify 31.2.2 [stream.types] as indicated:

    using streamoff = implementation-defined;

    -1- The type streamoff is a synonym for one of the signed basic integral types of sufficient size to represent the maximum possible file size for the operating system.256

    using streamsize = implementation-defined;

    -2- The type streamsize is a synonym for one of the signed basic integral types. It is used to represent the number of characters transferred in an I/O operation, or the size of I/O buffers.257

    256) Typically long long.

    257) Most places where streamsize is used would use size_t in C, or ssize_t in POSIX.