<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 3890: ABI issue for integer-class types</title>
<meta property="og:title" content="Issue 3890: ABI issue for integer-class types">
<meta property="og:description" content="C++ library issue. Status: New">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue3890.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="3890"><a href="lwg-active.html#3890">3890</a>. ABI issue for integer-class types</h3>
<p><b>Section:</b> 24.3.4.4 <a href="https://wg21.link/iterator.concept.winc">[iterator.concept.winc]</a> <b>Status:</b> <a href="lwg-active.html#New">New</a>
 <b>Submitter:</b> Jiang An <b>Opened:</b> 2023-02-19 <b>Last modified:</b> 2023-03-22</p>
<p><b>Priority: </b>3
</p>
<p><b>View all other</b> <a href="lwg-index.html#iterator.concept.winc">issues</a> in [iterator.concept.winc].</p>
<p><b>View all issues with</b> <a href="lwg-status.html#New">New</a> status.</p>
<p><b>Discussion:</b></p>
<p>
Currently integer-class types are required to be wider than every integer type 
(24.3.4.4 <a href="https://wg21.link/iterator.concept.winc">[iterator.concept.winc]</a>/3). As a result, if compiler provides extended integer types 
later whose width are not less than that of an integer-class type, then integer-class types with 
that width must be abandoned, which seems ABI-breaking (see also LWG <a href="lwg-defects.html#3828" title="Sync intmax_t and uintmax_t with C2x (Status: C++23)">3828</a><sup><a href="https://cplusplus.github.io/LWG/issue3828" title="Latest snapshot">(i)</a></sup>).
<p/>
I think we should allow some extended integer types to be wider than some integer-class types.
</p>

<p><i>[2023-03-22; Reflector poll]</i></p>

<p>
Set priority to 3 after reflector poll.
"Proposed resolution is insufficient. A lot of the wording depends on the fact
that the range of widths of integer-class types and that of integer types are
disjoint. And it also disallows signed integer -> unsigned integer-class
conversion and by extension mixed ops, which is seriously breaking (e.g., it
disallows <code>x += 1</code>)."
</p>



<p id="res-3890"><b>Proposed resolution:</b></p>
<p>
This wording is relative to <a href="https://wg21.link/N4928" title=" Working Draft, Standard for Programming Language C++">N4928</a>.
</p>

<ol>

<li><p>Modify 24.3.4.4 <a href="https://wg21.link/iterator.concept.winc">[iterator.concept.winc]</a> as indicated:</p>

<blockquote>
<p>
-3- The range of representable values of an integer-class type is the continuous set of values over which it is
defined. For any integer-class type, its range of representable values is either <code>-2<sup><i>N</i>-1</sup></code> to 
<code>2<sup><i>N</i>-1</sup> - 1</code> (inclusive) for some integer <code><i>N</i></code>, in which case it is a 
<i>signed-integer-class type</i>, or <code>0</code> to <code>2<sup><i>N</i></sup> - 1</code> (inclusive) for some integer
<code><i>N</i></code>, in which case it is an <i>unsigned-integer-class type</i>. In both cases, <code><i>N</i></code> is called 
the <i>width</i> of the integer-class type. The width of an integer-class type is greater than that of every 
<ins>standard</ins> integral type of the same signedness.
<p/>
[&hellip;]
<p/>
-6- Expressions of integer-class type are explicitly convertible to any integer-like type, and implicitly convertible
to any <ins>integral type or</ins> integer-class type of equal or greater width and the same signedness. 
Expressions of integral type are <del>both implicitly and</del> explicitly convertible to any integer-class type<ins>, 
and implicitly convertible to any integer-class type that can represent all values of the source type</ins>. 
Conversions between integral and integer-class types and between two integer-class types do not exit via an exception. 
The result of such a conversion is the unique value of the destination type that is congruent to the source modulo 
<code>2<sup><i>N</i></sup></code>, where <code><i>N</i></code> is the width of the destination type.
</p>
</blockquote>

</li>

</ol>





</body>
</html>
