This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/56862] std::complex constructor ambiguous overload
- From: "redi at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 01 Feb 2017 12:32:47 +0000
- Subject: [Bug libstdc++/56862] std::complex constructor ambiguous overload
- Auto-submitted: auto-generated
- References: <bug-56862-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56862
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution|--- |INVALID
--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to cbcode from comment #0)
> std::complex<double> cc(number()); //OK
This is only OK because it's a function declaration, not a variable definition.
See https://en.wikipedia.org/wiki/Most_vexing_parse
If you change it to be a variable then you get the same ambiguity:
std::complex<double> cc{number()}; // ambiguous
std::complex<double> cc = number(); // ambiguous
std::complex<double> cc = std::complex<double>(number()); // ambiguous
And that's correct, there are two user-defined conversions that can be used to
construct a std::complex<double> from a number, so this is not a bug.