<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 3696: "Basic integral types" should not be used</title>
<meta property="og:title" content="Issue 3696: &quot;Basic integral types&quot; should not be used">
<meta property="og:description" content="C++ library issue. Status: New">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue3696.html">
<meta property="og:type" content="website">
<meta property="og:image" content="http://cplusplus.github.io/LWG/images/cpp_logo.png">
<meta property="og:image:alt" content="C++ logo">
<style>
  p {text-align:justify}
  li {text-align:justify}
  pre code.backtick::before { content: "`" }
  pre code.backtick::after { content: "`" }
  blockquote.note
  {
    background-color:#E0E0E0;
    padding-left: 15px;
    padding-right: 15px;
    padding-top: 1px;
    padding-bottom: 1px;
  }
  ins {background-color:#A0FFA0}
  del {background-color:#FFA0A0}
  table.issues-index { border: 1px solid; border-collapse: collapse; }
  table.issues-index th { text-align: center; padding: 4px; border: 1px solid; }
  table.issues-index td { padding: 4px; border: 1px solid; }
  table.issues-index td:nth-child(1) { text-align: right; }
  table.issues-index td:nth-child(2) { text-align: left; }
  table.issues-index td:nth-child(3) { text-align: left; }
  table.issues-index td:nth-child(4) { text-align: left; }
  table.issues-index td:nth-child(5) { text-align: center; }
  table.issues-index td:nth-child(6) { text-align: center; }
  table.issues-index td:nth-child(7) { text-align: left; }
  table.issues-index td:nth-child(5) span.no-pr { color: red; }
  @media (prefers-color-scheme: dark) {
     html {
        color: #ddd;
        background-color: black;
     }
     ins {
        background-color: #225522
     }
     del {
        background-color: #662222
     }
     a {
        color: #6af
     }
     a:visited {
        color: #6af
     }
     blockquote.note
     {
        background-color: rgba(255, 255, 255, .10)
     }
  }
</style>
</head>
<body>
<hr>
<p><em>This page is a snapshot from the LWG issues list, see the <a href="lwg-active.html">Library Active Issues List</a> for more information and the meaning of <a href="lwg-active.html#New">New</a> status.</em></p>
<h3 id="3696"><a href="lwg-active.html#3696">3696</a>. "Basic integral types" should not be used</h3>
<p><b>Section:</b> 31.2.2 <a href="https://wg21.link/stream.types">[stream.types]</a> <b>Status:</b> <a href="lwg-active.html#New">New</a>
 <b>Submitter:</b> Jiang An <b>Opened:</b> 2022-05-07 <b>Last modified:</b> 2025-06-16</p>
<p><b>Priority: </b>3
</p>
<p><b>View all issues with</b> <a href="lwg-status.html#New">New</a> status.</p>
<p><b>Discussion:</b></p>
<p>
Raised from editorial issue <a href="https://github.com/cplusplus/draft/issues/5240">#5240</a>.
<p/>
The phrase "signed basic integral types" in 31.2.2 <a href="https://wg21.link/stream.types">[stream.types]</a> 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).
<p/>
As <code>std::streamoff</code> should be wide enough to represent the largest possible file size, and 
<code>std::uintmax_t</code> is used as the return type of <code>std::filesystem::file_size</code>, we should not 
disallow <code>std::streamoff</code> to be an extended integer type which may be wider than <code>long long</code>. 
On the other hand, as <code>std::size_t</code> and <code>std::ptrdiff_t</code> have already been allowed to be 
extended integer types, <code>std::streamsize</code> should also be allowed to be an extended integer type for consistency.
<p/>
So I think we should just use "signed integer types" instead of "signed basic integral types" in 
31.2.2 <a href="https://wg21.link/stream.types">[stream.types]</a>.
</p>

<p><i>[2022-05-17; Reflector poll]</i></p>

<p>
Set priority to 3 after reflector poll.
</p>

<p><i>[2025-06-16; Jonathan adds wording]</i></p>




<p id="res-3696"><b>Proposed resolution:</b></p>
<p>
This wording is relative to <a href="https://wg21.link/N5008" title=" Working Draft, Programming Languages — C++">N5008</a>.
</p>

<ol>
<li><p>Modify 31.2.2 <a href="https://wg21.link/stream.types">[stream.types]</a> as indicated:</p>

<blockquote>
<pre>using streamoff = implementation-defined;</pre>
<p>
-1- The type <code class='backtick'>streamoff</code> is a synonym for one of the
signed <del>basic</del> integral types
of sufficient size to represent the maximum possible file size
for the operating system.<sup>256</sup>
</p>
<pre>using streamsize = implementation-defined;</pre>
<p>
-2-
The type <code class='backtick'>streamsize</code> is a synonym for one of the
signed <del>basic</del> integral types.
It is used to represent the number of characters transferred
in an I/O operation, or the size of I/O buffers.<sup>257</sup>
</p>

<p>
<sub>256) Typically <code class='backtick'>long long</code>.</sub>
</p>
<p>
<sub>257) Most places where <code class='backtick'>streamsize</code> is used would use <code class='backtick'>size_t</code> in C,
or <code class='backtick'>ssize_t</code> in POSIX.</sub>
</p>
</blockquote>
</li>
</ol>






</body>
</html>
