<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Tue, Dec 30, 2014 at 11:07 AM, Abramo Bagnara <span dir="ltr"><<a href="mailto:abramo.bagnara@bugseng.com" target="_blank">abramo.bagnara@bugseng.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Il 11/11/2014 21:32, Richard Smith ha scritto:<br>
<span class=""><br>
> This change is incorrect. The usual arithmetic conversions do *not*<br>
> take `(_Complex double, double)` to `(_Complex double, _Complex<br>
> double)`; note C11 <a href="http://6.13.1.8/1" target="_blank">6.13.1.8/1</a> ("... without change of type domain").<br>
<br>
</span>I guess that this justify why after r219557 we don't have any longer a<br>
FloatingRealToComplex implicit cast for `c' in `b = c + b' below, right?<br>
<br>
_Complex float b;<br>
<br>
void foo (void)<br>
{<br>
  float c = 1.0;<br>
  b = c + b;<br>
}<br></blockquote><div><br></div><div>That's correct.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
The puzzling thing is that we still generates implicit<br>
FloatingRealToComplex implicit cast for:<br>
<br>
_Complex float b;<br>
<br>
void foo (void)<br>
{<br>
  int c = 1;<br>
  b = c + b;<br>
}<br>
<br>
Is this a bug?<br></blockquote><div><br></div><div>Yes, that's a bug. Note that this leads to us computing the wrong answer here:</div><div><br></div><div>_Complex float a = __builtin_inf();</div><div>_Complex float b = a * 1;<br></div><div><br></div><div>(If you promote first, you get Inf + NaN i; otherwise, you get Inf + 0 i.)</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I'm also wondering if it is a savy choice (standard apart) to omit such<br>
kind of implicit conversions from AST considering that indeed they<br>
"happens" (taken for granted we have also other implicit casts that<br>
standard does not strictly requires).</blockquote><div><br></div><div>See example above. The implicit conversion does *not* actually "happen"; the mixed-mode multiplication does not compute the same result as promoting to _Complex and then performing the computation.</div></div></div></div>