[Bug c++/105111] Ambiguous constructor overload with requires constraint

ppalka at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Wed Mar 30 18:55:03 GMT 2022


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

Patrick Palka <ppalka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |DUPLICATE
             Status|UNCONFIRMED                 |RESOLVED
                 CC|                            |ppalka at gcc dot gnu.org

--- Comment #1 from Patrick Palka <ppalka at gcc dot gnu.org> ---
(In reply to Andrei-Edward Popa from comment #0)
> I think this is a bug because the most constrained constructor is the first
> one and has a matching requires clause when we create the s object.

According to the standard (http://eel.is/c++draft/temp.func.order#6), "more
constrained" is used as a tiebreaker between two functions only if their
(function and template) parameter lists are equivalent.  In your example the
function parameter lists different ('T' vs 'const T&'), so I believe GCC is
correct to reject the call as ambiguous.  If other compilers accept it, it's
probably because they don't implement wg21.link/p2113r0 (which changed this
part of the standard).

*** This bug has been marked as a duplicate of bug 96333 ***


More information about the Gcc-bugs mailing list