<html><head><style type='text/css'>p { margin: 0; }</style></head><body><div style='font-family: arial,helvetica,sans-serif; font-size: 10pt; color: #000000'><br><hr id="zwchr"><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px; color: rgb(0, 0, 0); font-weight: normal; font-style: normal; text-decoration: none; font-family: Helvetica,Arial,sans-serif; font-size: 12pt;"><b>From: </b>"Martin J. O'Riordan" <martin.oriordan@movidius.com><br><b>To: </b>"Hal Finkel" <hfinkel@anl.gov><br><b>Cc: </b>"Marshall Clow" <mclow.lists@gmail.com>, "Richard Smith" <richard@metafoo.co.uk>, "Clang Dev" <cfe-dev@lists.llvm.org>, "Eric Fiselier" <eric@efcs.ca><br><b>Sent: </b>Saturday, January 23, 2016 4:23:21 PM<br><b>Subject: </b>RE: [cfe-dev] LibC++ v3.8 - Problems with ISO C wrapper headers<br><br>
<style><!--
@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;}
@font-face
{font-family:"Book Antiqua";
panose-1:2 4 6 2 5 3 5 3 3 4;}
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman",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
{mso-style-priority:99;
margin:0cm;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman",serif;}
span.EmailStyle18
{mso-style-type:personal;
font-family:"Book Antiqua",serif;
color:#943634;
font-weight:normal;
font-style:normal;
text-decoration:none none;}
span.EmailStyle19
{mso-style-type:personal-reply;
font-family:"Book Antiqua",serif;
color:#943634;
font-weight:normal;
font-style:normal;
text-decoration:none none;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
{page:WordSection1;}
--></style><div class="WordSection1"><p class="MsoNormal"><b><span style="font-size: 11pt; font-family: "Calibri",sans-serif;" lang="EN-US">From:</span></b><span style="font-size: 11pt; font-family: "Calibri",sans-serif;" lang="EN-US"> Hal Finkel [mailto:hfinkel@anl.gov] <br><b>Sent:</b> 23 January 2016 21:57<br><b>To:</b> Martin ORiordan <Martin.ORiordan@Movidius.com><br><b>Cc:</b> Marshall Clow <mclow.lists@gmail.com>; Richard Smith <richard@metafoo.co.uk>; Clang Dev <cfe-dev@lists.llvm.org>; Eric Fiselier <eric@efcs.ca><br><b>Subject:</b> Re: [cfe-dev] LibC++ v3.8 - Problems with ISO C wrapper headers</span></p><p class="MsoNormal"> </p><div><blockquote style="border-width: medium medium medium 1.5pt; border-style: none none none solid; border-color: -moz-use-text-color -moz-use-text-color -moz-use-text-color rgb(16, 16, 255); padding: 0cm 0cm 0cm 4pt; margin-left: 3.75pt; margin-top: 5pt; margin-bottom: 5pt;"><p class="MsoNormal"><span style="font-family: "Book Antiqua",serif; color: rgb(148, 54, 52);">The effective code subtly changes silently from:</span><span style="color: black;"></span></p><p class="MsoNormal"><span style="font-family: "Book Antiqua",serif; color: rgb(148, 54, 52);"> </span><span style="color: black;"></span></p><p class="MsoNormal" style="margin-left: 36pt;"><span style="font-family: "Courier New",serif; color: black;">int x = abs((int)aBar.operator double()); // choosing ‘int ::abs(int)’</span><span style="color: black;"></span></p><p class="MsoNormal"><span style="font-family: "Book Antiqua",serif; color: rgb(148, 54, 52);">to:</span><span style="color: black;"></span></p><p class="MsoNormal" style="margin-left: 36pt;"><span style="font-family: "Courier New",serif; color: black;">int x = (int)abs(aBar.operator double()); // choosing ‘double ::abs(double)’</span><span style="color: black;"></span></p></blockquote><p class="MsoNormal"><span style="font-size: 10pt; font-family: "Arial",sans-serif; color: black;">Of all of your examples, this is the most important. The other changes result in a compilation failure, and are easy to fix. However, it is certainly my experience that, in almost all cases, the semantic change you highlight is actually a silent bug *fix*, as the author almost always intended the behavior we now have, not the behavior we provided previously. Obviously this will not be 100% true, but on balance, the change has seems positive. Either way, good compiler warnings are essential. As I recall, Clang does have a good warning for this.<br><br> -Hal</span></p><p class="MsoNormal"><span style="font-family: "Book Antiqua",serif; color: rgb(148, 54, 52);"> </span></p><p class="MsoNormal"><span style="font-family: "Book Antiqua",serif; color: rgb(148, 54, 52);">Hmm, yes and no. If they wanted different behaviour, they should have included ‘</span><span style="font-family: "Courier New",serif; color: black;"><cmath></span><span style="font-family: "Book Antiqua",serif; color: rgb(148, 54, 52);">’ and not ‘</span><span style="font-family: "Courier New",serif; color: black;"><math.h></span><span id="DWT3686" style="font-family: "Book Antiqua",serif; color: rgb(148, 54, 52);">’. It is not our place to assume to fix their possible intent. An expert C++ programmer might expect exactly the C behaviour. </span></p></div></div></blockquote>I'd have a difficult time calling such an author an expert C++ programmer, as such a person would clearly understand how easy it would be for some future maintainer to break their code by a seemingly-innocuous improvement in which headers are included, or by placing the code in a different environment (e.g. by someone copying-and-pasting the code into some other file).<br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px; color: rgb(0, 0, 0); font-weight: normal; font-style: normal; text-decoration: none; font-family: Helvetica,Arial,sans-serif; font-size: 12pt;"><div class="WordSection1"><div><p class="MsoNormal"><span id="DWT3687" style="font-family: "Book Antiqua",serif; color: rgb(148, 54, 52);"> The very fact that they chose the C header</span></p></div></div></blockquote><br>But it is often not the choice of the original author, at least not intentionally.<br><br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px; color: rgb(0, 0, 0); font-weight: normal; font-style: normal; text-decoration: none; font-family: Helvetica,Arial,sans-serif; font-size: 12pt;"><div class="WordSection1"><div><p class="MsoNormal"><span id="DWT3697" style="font-family: "Book Antiqua",serif; color: rgb(148, 54, 52);"> and not the C++ prescribed equivalent makes it more evident to me that this is the realm of the static analyser’s diagnostics, and not the realm of the Standard library implementation to assume it knows what they might have meant.</span></p></div></div></blockquote>I think your position is completely reasonable, but there happen to be strong practical advantages to the wording as-stated that are definitely worth considering (regardless of how we got here).<br><br> -Hal<br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px; color: rgb(0, 0, 0); font-weight: normal; font-style: normal; text-decoration: none; font-family: Helvetica,Arial,sans-serif; font-size: 12pt;"><div class="WordSection1"><div><p class="MsoNormal"><span style="font-family: "Book Antiqua",serif; color: rgb(148, 54, 52);"></span></p><p class="MsoNormal"><span style="font-family: "Book Antiqua",serif; color: rgb(148, 54, 52);"> </span></p><p class="MsoNormal"><span style="font-family: "Book Antiqua",serif; color: rgb(148, 54, 52);"> MartinO</span></p><p class="MsoNormal"><span style="font-family: "Book Antiqua",serif; color: rgb(148, 54, 52);"> </span></p></div></div></blockquote><br><br><br>-- <br><div><span name="x"></span>Hal Finkel<br>Assistant Computational Scientist<br>Leadership Computing Facility<br>Argonne National Laboratory<span name="x"></span><br></div></div></body></html>