<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p.msonormal0, li.msonormal0, div.msonormal0
        {mso-style-name:msonormal;
        mso-margin-top-alt:auto;
        margin-right:0in;
        mso-margin-bottom-alt:auto;
        margin-left:0in;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
span.EmailStyle19
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
span.msoDel
        {mso-style-type:export-only;
        mso-style-name:"";
        text-decoration:line-through;
        color:red;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri",sans-serif;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal">I think we mostly agree it’s unfortunate that C conflated (for example) “character” and “small integer” and “raw memory” into the same type, “char.” Ideally those would be distinct types, and “integer” would support arithmetic +-*/etc.
but not also support text- or bit-specific operations at all. (That’s a major reason we created a std::byte that supports bit-ops, but not text or arithmetic.)<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">So, in that light…<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">> the status quo is inconsistent, and satisfies neither the "<< means multiplication" nor the
<o:p></o:p></p>
<p class="MsoNormal">> "<< means bit shift" perspective. I want one or the other, or a really good reason for the status quo.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">… for an integer type we’d want (in an ideal world) all operations to be arithmetic, and no bit-ops. Right? If so, +1 for multiplication.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Of course there may be other issues here, such as historical and/or consistency. I’m just throwing in an ‘ideal world’ perspective as a data point in case it helps inform deciding between feasible options, I’m not steeped in this to know
whether it’s the right answer all-up in this case.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt">
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b>From:</b> ub-bounces@open-std.org <ub-bounces@open-std.org>
<b>On Behalf Of </b>Richard Smith<br>
<b>Sent:</b> Friday, March 16, 2018 3:48 PM<br>
<b>To:</b> ub <ub@open-std.org><br>
<b>Subject:</b> Re: [ub] An update on signed integers<o:p></o:p></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<div>
<div>
<p class="MsoNormal">On Fri, 16 Mar 2018, 14:20 Arthur O'Dwyer, <<a href="mailto:arthur.j.odwyer@gmail.com">arthur.j.odwyer@gmail.com</a>> wrote:<o:p></o:p></p>
</div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<div>
<p class="MsoNormal">(Dropped some marginally relevant lists I get mod-queued on anyway)<o:p></o:p></p>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">> <span style="font-size:9.5pt">The notes should help clarify RIchard's rationale for proposing this.</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal"><a href="http://wiki.edg.com/bin/view/Wg21jacksonville2018/Sg6P0907R0" target="_blank">http://wiki.edg.com/bin/view/Wg21jacksonville2018/Sg6P0907R0</a> has some discussion from Richard (Smith?) about (1<<32) needing to remain IDB-at-best
on x86 platforms (Ctrl+F "crypto"). Total agreement on that front.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">I don't see any notes on that page which are relevant to (1<<31) — there's just the straw poll results with zero prior discussion notated.<o:p></o:p></p>
</div>
</div>
</blockquote>
</div>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">My rationale for wanting *some* change here is that the status quo is inconsistent, and satisfies neither the "<< means multiplication" nor the "<< means bit shift" perspective. I want one or the other, or a really good reason for the status
quo.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">And, FWIW, the bit shift option was my preference.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<div>
<div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<p class="MsoNormal">Shifting out of range (1 << 31) as currently defined (if shift has defined value when interpreted as unsigned, you get the value as signed, you can dhigt into but not past the sign, shifting past sign bit is UB), 1<<31 was defined and still
is (as of Howard's paper), 2<<31 was UB and still is, WG14 is currently considering whether to adopt Howard's paper which made this. Should we take it back to undefined to do 1<<31?<br>
SS F N A SA<br>
2 7 5 1 1<o:p></o:p></p>
</blockquote>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Am I looking at the wrong page, perhaps?<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Thanks,<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">Arthur<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<div>
<p class="MsoNormal">P.S. — Alternatively, since 0x80000000 is allowed to be a trap representation in P0907r1 but 0xC0000000 is not, perhaps the intent of this straw poll was that 1<<31 should be UB but 3<<30 should be well-defined. That would be extra weird,
though, so I hope that's not what happened.<o:p></o:p></p>
</div>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal">On Fri, Mar 16, 2018 at 11:06 AM, JF Bastien <<a href="mailto:cxx@jfbastien.com" target="_blank">cxx@jfbastien.com</a>> wrote:<o:p></o:p></p>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<div>
<div>
<div>
<p class="MsoNormal">On Fri, Mar 16, 2018 at 2:04 PM, Arthur O'Dwyer <<a href="mailto:arthur.j.odwyer@gmail.com" target="_blank">arthur.j.odwyer@gmail.com</a>> wrote:<o:p></o:p></p>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<div>
<p class="MsoNormal">P0907r1 proposes this addition relative to the WD:<o:p></o:p></p>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">> <u><span style="font-size:13.5pt;font-family:"Arial",sans-serif;color:#008800">If overflow caused by an operation which would require representing an integer which cannot be represented by the type, the behavior is undefined.</span></u><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">However, it simultaneously proposes these deletions relative to the WD:<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">> <s><span style="font-size:13.5pt;font-family:"Arial",sans-serif;color:red">[</span></s><em><s><span style="font-family:"Arial",sans-serif;color:red">Note:</span></s></em><s><span style="font-size:13.5pt;font-family:"Arial",sans-serif;color:red"> Operators
can be regrouped according to the usual mathematical rules only where the operators really are associative or commutative </span></s>...<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">and<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">> <span style="font-family:"Arial",sans-serif;color:black">an operation that would have undefined behavior as specified in Clause 4 through 19 of this document [<em><span style="font-family:"Arial",sans-serif">Note</span></em>: including,
for example, </span><span style="font-family:"Arial",sans-serif;color:red"><span class="msoDel"><del>signed integer overflow, </del></span></span><span style="font-family:"Arial",sans-serif;color:black">certain pointer arithmetic, division by zero, or certain
shift operations —<em><span style="font-family:"Arial",sans-serif">end note</span></em>]</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">The removals are all non-normative, but they seem to be aimed at eliminating references to "signed overflow is UB", even though signed overflow
<i>is</i> still UB. Was there a sense in the room that we wanted to downplay the importance of
<i>teaching</i> signed UB in C++, but not actually eliminate the UB itself? Or what's the point of re-wording these existing notes?<o:p></o:p></p>
</div>
</div>
</blockquote>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">There was extensive discussion of this note, what to add / remove, etc, and no direction as to where to go. I'll ask EWG today.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<div>
<div>
<p class="MsoNormal">Also, separately and less importantly, I'd love to hear someone's rationale for making (1<<31) UB in C++2a when it's IDB in C++17. The straw poll result in P0907r1 sounds unambiguous, but I don't understand what rationale could exist for
taking this construct from IDB into UB. Is the assumption that people haven't yet had a chance to write any programs whose correctness depends on the value of (1<<31), so if we change it back to UB fast enough, nobody will notice?<o:p></o:p></p>
</div>
</div>
</blockquote>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">The notes should help clarify RIchard's rationale for proposing this.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<div>
<div>
<p class="MsoNormal">–Arthur<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<div>
<p class="MsoNormal">On Fri, Mar 16, 2018 at 8:56 AM, JF Bastien <<a href="mailto:cxx@jfbastien.com" target="_blank">cxx@jfbastien.com</a>> wrote:<o:p></o:p></p>
</div>
</div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<div>
<div>
<div>
<p class="MsoNormal">Hello EWG,<o:p></o:p></p>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">SG6 and SG12 discussed <a href="http://wg21.link/P0907r0" target="_blank">
wg21.link/P0907r0</a> Signed Integers are Two’s Complement and provided extensive feedback.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">I've attached an updated paper listing polls and addressing most feedback (except some wording fiddle) to the EWG wiki for this afternoon's discussion:<o:p></o:p></p>
</div>
<blockquote style="margin-left:30.0pt;margin-right:0in">
<div>
<p class="MsoNormal"><a href="http://wiki.edg.com/pub/Wg21jacksonville2018/EvolutionWorkingGroup/D0907r1.html" target="_blank">http://wiki.edg.com/pub/Wg21jacksonville2018/EvolutionWorkingGroup/D0907r1.html</a><o:p></o:p></p>
</div>
</blockquote>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Thanks,<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">JF<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</div>
<p class="MsoNormal" style="margin-bottom:12.0pt">_______________________________________________<br>
ub mailing list<br>
<a href="mailto:ub@isocpp.open-std.org" target="_blank">ub@isocpp.open-std.org</a><br>
<a href="http://www.open-std.org/mailman/listinfo/ub" target="_blank">http://www.open-std.org/mailman/listinfo/ub</a><o:p></o:p></p>
</blockquote>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</div>
</blockquote>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</div>
</blockquote>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<p class="MsoNormal">_______________________________________________<br>
ub mailing list<br>
<a href="mailto:ub@isocpp.open-std.org" target="_blank">ub@isocpp.open-std.org</a><br>
<a href="http://www.open-std.org/mailman/listinfo/ub" target="_blank">http://www.open-std.org/mailman/listinfo/ub</a><o:p></o:p></p>
</blockquote>
</div>
</div>
</div>
</div>
</div>
</body>
</html>