[Bug c++/31780] [4.2/4.3 regression] ICE with incompatible types for ?: with "complex type" conversion

mark at codesourcery dot com gcc-bugzilla@gcc.gnu.org
Tue Jan 22 18:05:00 GMT 2008



------- Comment #38 from mark at codesourcery dot com  2008-01-22 17:47 -------
Subject: Re:  [4.2/4.3 regression] ICE with incompatible types
 for ?: with "complex type" conversion

jason at gcc dot gnu dot org wrote:

>> However, this runs into problems with libstdc++.  In particular,
>> std::complex<double> has a constructor from double and also a constructor from
>> __complex__ double.  Making the change in this patch makes that conversion
>> ambiguous because now "std::complex<double>(1)" can go via either the
>> "__complex__ double" constructor or the plain "double" constructor.
> 
> It seems clear to me that conversion to complex should be worse than conversion
> to another scalar arithmetic type.  I would implement this in hypothetical
> standardese by defining "complex conversions" for the conversion from scalar to
> complex, and the term "scalar arithmetic conversions" for integer, float and
> integer-float conversions, then adding to 13.3.3.2p3 an additional rule that S1
> is better than S2 if S1 is a scalar arithmetic conversion and S2 is a complex
> conversion.

Yes, that would probably work.  I would prefer to avoid a whole new
class of conversions, and it doesn't seem necessary to me, since I still
don't understand what Gaby is worried about.  But, it does seem like a
technically feasible solution if absolutely necessary.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31780



More information about the Gcc-bugs mailing list