[Bug c++/87676] Presence of variadic constructor template breaks overload resolution for other constructors

redi at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Mon Oct 22 08:57:00 GMT 2018


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87676

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Jonathan Wakely from comment #1)
> The template constructor allows s({1, 2, 3}) to mean s(S2{1,2,3}) which
> tries to use the deleted copy constructor.

Or more precisely, overload resolution means that the deleted constructor is
viable, because there's a conversion sequence from the braced-init-list to the
parameter type of the deleted copy constructor. The S2(S1&&) function is also
viable, and neither is a better match, so it's ambiguous.

The S2(const S1&) constructor is also viable, but is a worse match than
S2(S1&&) and so would not actually get chosen, but is still shown as one of the
candidates.


More information about the Gcc-bugs mailing list