This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/31780] [4.2/4.3 regression] ICE with incompatible types for ?: with "complex type" conversion
- From: "jason at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 22 Jan 2008 15:37:51 -0000
- Subject: [Bug c++/31780] [4.2/4.3 regression] ICE with incompatible types for ?: with "complex type" conversion
- References: <bug-31780-1771@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #37 from jason at gcc dot gnu dot org 2008-01-22 15:37 -------
(In reply to comment #7)
> Since complex types are arithmetic types in GNU C++, we should allow standard
> conversions to them from integers, just as we do for all other arithmetic
> types.
>
> 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.
I think this approach would avoid the need for extra constructors.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31780