This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libstdc++/56862] std::complex constructor ambiguous overload


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.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]