<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<TITLE>
    CWG Issue 2484</TITLE>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<STYLE TYPE="text/css">
  INS { text-decoration:none; font-weight:bold; background-color:#A0FFA0 }
  .INS { text-decoration:none; background-color:#D0FFD0 }
  DEL { text-decoration:line-through; background-color:#FFA0A0 }
  .DEL { text-decoration:line-through; background-color: #FFD0D0 }
  @media (prefers-color-scheme: dark) {
    HTML { background-color:#202020; color:#f0f0f0; }
    A { color:#5bc0ff; }
    A:visited { color:#c6a8ff; }
    A:hover, a:focus { color:#afd7ff; }
    INS { background-color:#033a16; color:#aff5b4; }
    .INS { background-color: #033a16; }
    DEL { background-color:#67060c; color:#ffdcd7; }
    .DEL { background-color:#67060c; }
  }
  SPAN.cmnt { font-family:Times; font-style:italic }
</STYLE>
</HEAD>
<BODY>
<P><EM>This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21
  Core Issues List revision 118b.
  See http://www.open-std.org/jtc1/sc22/wg21/ for the official
  list.</EM></P>
<P>2025-09-28</P>
<HR>
<A NAME="2484"></A><H4>2484.
  
<TT>char8_t</TT> and <TT>char16_t</TT> in integral promotions
</H4>
<B>Section: </B>7.3.7&#160; [<A href="https://wg21.link/conv.prom">conv.prom</A>]
 &#160;&#160;&#160;

 <B>Status: </B>CD6
 &#160;&#160;&#160;

 <B>Submitter: </B>Richard Smith
 &#160;&#160;&#160;

 <B>Date: </B>2021-04-01<BR>


<P>[Accepted as a DR at the October, 2021 meeting.]</P>

<P>According to 7.3.7 [<A href="https://wg21.link/conv.prom">conv.prom</A>] paragraphs 1-2,</P>

<BLOCKQUOTE>

<P>A prvalue of an integer type other than <TT>bool</TT>,
<TT>char16_t</TT>, <TT>char32_t</TT>, or <TT>wchar_t</TT>
whose integer conversion rank (6.9.6 [<A href="https://wg21.link/conv.rank">conv.rank</A>])
is less than the rank of <TT>int</TT> can be converted to a
prvalue of type <TT>int</TT> if <TT>int</TT> can represent
all the values of the source type; otherwise, the source
prvalue can be converted to a prvalue of type <TT>unsigned
int</TT>.</P>

<P>A prvalue of type <TT>char16_t</TT>, <TT>char32_t</TT>,
or <TT>wchar_t</TT> (6.9.2 [<A href="https://wg21.link/basic.fundamental">basic.fundamental</A>]) can be
converted to a prvalue of the first of the following types
that can represent all the values of its underlying type:
<TT>int</TT>, <TT>unsigned int</TT>, <TT>long int</TT>,
<TT>unsigned long int</TT>, <TT>long long int</TT>, or
<TT>unsigned long long int</TT>. If none of the types in that
list can represent all the values of its underlying type, a
prvalue of type <TT>char16_t</TT>, <TT>char32_t</TT>, or
<TT>wchar_t</TT> can be converted to a prvalue of its
underlying type.</P>

</BLOCKQUOTE>

<P>Because of its omission from the list of excluded types
(perhaps as an oversight when it was
added), <TT>char8_t</TT> is handled in the first
paragraph. However, <TT>char16_t</TT> falls into the second
paragraph, even though it is guaranteed to be convertible
to <TT>int</TT> or <TT>unsigned int</TT>. This seems
inconsistent, so perhaps <TT>char8_t</TT> should be moved to
the second paragraph or <TT>char16_t</TT> moved to the first?</P>

<P><B>Notes from the August, 2021 teleconference:</B></P>

<P>
<TT>char8_t</TT> should be handled by the second
paragraph by including it in all three lists of types in the
two paragraphs.</P>

<P><B>Proposed resolution (August, 2021):</B></P>

<P>Change 7.3.7 [<A href="https://wg21.link/conv.prom">conv.prom</A>] paragraphs 1 and 2 as follows:</P>

<BLOCKQUOTE>

<P>A prvalue of an integer type other
than <TT>bool</TT>, <INS><TT>char8_t</TT>,</INS>
<TT>char16_t</TT>, <TT>char32_t</TT>, or <TT>wchar_t</TT>
whose integer conversion rank (6.9.6 [<A href="https://wg21.link/conv.rank">conv.rank</A>])
is less than the rank of <TT>int</TT> can be converted to a
prvalue of type <TT>int</TT> if <TT>int</TT> can represent
all the values of the source type; otherwise, the source
prvalue can be converted to a prvalue of type <TT>unsigned
int</TT>.</P>

<P>A prvalue of type <INS><TT>char8_t</TT>,</INS>
<TT>char16_t</TT>, <TT>char32_t</TT>,
or <TT>wchar_t</TT> (6.9.2 [<A href="https://wg21.link/basic.fundamental">basic.fundamental</A>]) can be
converted to a prvalue of the first of the following types
that can represent all the values of its underlying type:
<TT>int</TT>, <TT>unsigned int</TT>, <Tt>long int</Tt>,
<TT>unsigned long int</TT>, <TT>long long int</TT>, or
<TT>unsigned long long int</TT>. If none of the types in
that list can represent all the values of its underlying
type, a prvalue of type <INS><TT>char8_t</TT>,</INS>
<TT>char16_t</TT>, <TT>char32_t</TT>,
or <TT>wchar_t</TT> can be converted to a prvalue of its
underlying type.</P>

</BLOCKQUOTE>

<BR><BR>
</BODY>
</HTML>
