<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><br><div><div>On 04 Sep 2014, at 15:23, Abramo Bagnara <<a href="mailto:abramo.bagnara@bugseng.com">abramo.bagnara@bugseng.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">Il 04/09/2014 15:13, Abramo Bagnara ha scritto:<br><blockquote type="cite"><br>For the following source<br><br>void f() {<br> char *p;<br> const char *cp;<br> p == cp;<br> p != cp;<br> p < cp;<br> p <= cp;<br> p > cp;<br> p >= cp;<br> p - cp;<br>}<br><br>clang (unexpectedly for me) emits an implicit cast from const char * to<br>char * (i.e. it remove a qualifier) for all the relational and equality<br></blockquote><br>BTW: this violates C++11 5.9p2 where it is said that<br><br>"Otherwise, the composite pointer type is a pointer type similar (4.4)<br>to the type of one of the operands, with a cv-qualification signature<br>(4.4) that is the union of the cv-qualification signatures of the<br>operand types.”<br><br></div></blockquote><div><br></div>Interestingly enough, if I compile it as C, I get the const -> non-const casts, whereas as C++, I get them the other way round, conforming to the standard.</div><div><br></div><div>C++:</div><div><div style="margin: 0px; font-size: 11px; font-family: Menlo; color: rgb(175, 173, 36);"><span style="color: #5330e1">    |-</span><span style="color: #d53bd3"><b>BinaryOperator</b></span> 0x102824568<span style="color: #000000"> <</span>line:4:2<span style="color: #000000">, </span>col:7<span style="color: #000000">> </span><span style="color: #34bd26">'_Bool'</span><span style="color: #000000"> '=='</span></div><div style="margin: 0px; font-size: 11px; font-family: Menlo; color: rgb(175, 173, 36);"><span style="color: #5330e1">    | |-</span><span style="color: #d53bd3"><b>ImplicitCastExpr</b></span> 0x102824550<span style="color: #000000"> <</span>col:2<span style="color: #000000">> </span><span style="color: #34bd26">'const char *'</span><span style="color: #000000"> <</span><span style="color: #c33720">NoOp</span><span style="color: #000000">></span></div><div style="margin: 0px; font-size: 11px; font-family: Menlo; color: rgb(175, 173, 36);"><span style="color: #5330e1">    | | `-</span><span style="color: #d53bd3"><b>ImplicitCastExpr</b></span> 0x102824520<span style="color: #000000"> <</span>col:2<span style="color: #000000">> </span><span style="color: #34bd26">'char *'</span><span style="color: #000000"> <</span><span style="color: #c33720">LValueToRValue</span><span style="color: #000000">></span></div><div style="margin: 0px; font-size: 11px; font-family: Menlo; color: rgb(175, 173, 36);"><span style="color: #5330e1">    | |   `-</span><span style="color: #d53bd3"><b>DeclRefExpr</b></span> 0x1028244d0<span style="color: #000000"> <</span>col:2<span style="color: #000000">> </span><span style="color: #34bd26">'char *'</span><span style="color: #34bbc7"> lvalue</span><span style="color: #000000"> </span><span style="color: #34bd26"><b>Var</b></span> 0x1028243b0<span style="color: #34bbc7"><b> 'p'</b></span><span style="color: #000000"> </span><span style="color: #34bd26">'char *'</span></div><div style="margin: 0px; font-size: 11px; font-family: Menlo; color: rgb(175, 173, 36);"><span style="color: #5330e1">    | `-</span><span style="color: #d53bd3"><b>ImplicitCastExpr</b></span> 0x102824538<span style="color: #000000"> <</span>col:7<span style="color: #000000">> </span><span style="color: #34bd26">'const char *'</span><span style="color: #000000"> <</span><span style="color: #c33720">LValueToRValue</span><span style="color: #000000">></span></div><div style="margin: 0px; font-size: 11px; font-family: Menlo; color: rgb(52, 189, 38);"><span style="color: #5330e1">    |   `-</span><span style="color: #d53bd3"><b>DeclRefExpr</b></span><span style="color: #afad24"> 0x1028244f8</span><span style="color: #000000"> <</span><span style="color: #afad24">col:7</span><span style="color: #000000">> </span>'const char *'<span style="color: #34bbc7"> lvalue</span><span style="color: #000000"> </span><b>Var</b><span style="color: #afad24"> 0x102824460</span><span style="color: #34bbc7"><b> 'cp'</b></span><span style="color: #000000"> </span>'const char *'</div><div><br></div>C:</div><div><div style="margin: 0px; font-size: 11px; font-family: Menlo; color: rgb(175, 173, 36);"><span style="color: #5330e1">    |-</span><span style="color: #d53bd3"><b>BinaryOperator</b></span> 0x1028224b8<span style="color: #000000"> <</span>line:4:2<span style="color: #000000">, </span>col:7<span style="color: #000000">> </span><span style="color: #34bd26">'int'</span><span style="color: #000000"> '=='</span></div><div style="margin: 0px; font-size: 11px; font-family: Menlo; color: rgb(175, 173, 36);"><span style="color: #5330e1">    | |-</span><span style="color: #d53bd3"><b>ImplicitCastExpr</b></span> 0x102822470<span style="color: #000000"> <</span>col:2<span style="color: #000000">> </span><span style="color: #34bd26">'char *'</span><span style="color: #000000"> <</span><span style="color: #c33720">LValueToRValue</span><span style="color: #000000">></span></div><div style="margin: 0px; font-size: 11px; font-family: Menlo; color: rgb(175, 173, 36);"><span style="color: #5330e1">    | | `-</span><span style="color: #d53bd3"><b>DeclRefExpr</b></span> 0x102822420<span style="color: #000000"> <</span>col:2<span style="color: #000000">> </span><span style="color: #34bd26">'char *'</span><span style="color: #34bbc7"> lvalue</span><span style="color: #000000"> </span><span style="color: #34bd26"><b>Var</b></span> 0x102822300<span style="color: #34bbc7"><b> 'p'</b></span><span style="color: #000000"> </span><span style="color: #34bd26">'char *'</span></div><div style="margin: 0px; font-size: 11px; font-family: Menlo; color: rgb(175, 173, 36);"><span style="color: #5330e1">    | `-</span><span style="color: #d53bd3"><b>ImplicitCastExpr</b></span> 0x1028224a0<span style="color: #000000"> <</span>col:7<span style="color: #000000">> </span><span style="color: #34bd26">'char *'</span><span style="color: #000000"> <</span><span style="color: #c33720">BitCast</span><span style="color: #000000">></span></div><div style="margin: 0px; font-size: 11px; font-family: Menlo; color: rgb(175, 173, 36);"><span style="color: #5330e1">    |   `-</span><span style="color: #d53bd3"><b>ImplicitCastExpr</b></span> 0x102822488<span style="color: #000000"> <</span>col:7<span style="color: #000000">> </span><span style="color: #34bd26">'const char *'</span><span style="color: #000000"> <</span><span style="color: #c33720">LValueToRValue</span><span style="color: #000000">></span></div><div style="margin: 0px; font-size: 11px; font-family: Menlo; color: rgb(52, 189, 38);"><span style="color: #5330e1">    |     `-</span><span style="color: #d53bd3"><b>DeclRefExpr</b></span><span style="color: #afad24"> 0x102822448</span><span style="color: #000000"> <</span><span style="color: #afad24">col:7</span><span style="color: #000000">> </span>'const char *'<span style="color: #34bbc7"> lvalue</span><span style="color: #000000"> </span><b>Var</b><span style="color: #afad24"> 0x1028223b0</span><span style="color: #34bbc7"><b> 'cp'</b></span><span style="color: #000000"> </span>'const char *'</div><p style="margin: 0px; font-size: 11px; font-family: Menlo; color: rgb(83, 48, 225); min-height: 13px;"> <br class="webkit-block-placeholder"></p></div><div>So it appears to be separate code paths for the two languages.</div><div><br></div>Sebastian</body></html>