[Bug c++/94124] [10 Regression] conversion from ‘<brace-enclosed initializer list>’ to ‘F’ is ambiguous since r10-6388-ge98ebda074bf8fc5

mpolacek at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Wed Mar 11 03:15:59 GMT 2020


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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED

--- Comment #4 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
commit e11d05c1ed26257493130762a8ae240f1bc06e87
Author: Marek Polacek <polacek@redhat.com>
Date:   Tue Mar 10 18:55:42 2020 -0400

    c++: Fix wrong conversion error with non-viable overload [PR94124]

    This is a bad interaction between sharing a constructor for an array
    and stripping its trailing zero-initializers.  Here we reuse a ctor
    and then strip its 0s.  This breaks overload resolution in this test:
    D can be initialized from {} but not from {0}, so if we truncate the
    constructor not to include the zero, the F(D) overload becomes valid
    and then we get the ambiguous conversion error.

            PR c++/94124 - wrong conversion error with non-viable overload.
            * decl.c (reshape_init_array_1): Unshare a constructor if we
            stripped trailing zero-initializers.

            * g++.dg/cpp0x/initlist-overload1.C: New test.


More information about the Gcc-bugs mailing list