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

            Bug ID: 92400
           Summary: Incorrect selection of constructor overload for brace
                    list
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: thiago at kde dot org
  Target Milestone: ---

Godbolt link: https://gcc.godbolt.org/z/bckr_n
Testcase:

#include <initializer_list>

struct A;
struct V
{
    V() = default;
    V(const A &);
    A make_a() const;
};

struct A
{
    A();
    A(const A &);
    A(A &&);
    A(std::initializer_list<V>);
};

void sink(A &);
void f()
{
    A a{ V().make_a() };
    sink(a);
}

When compiled, GCC generates a call to A::A(std::initializer_list<V>). The
three other compilers in the test do not -- ICC has a call to A::A(A&&) and
Clang can be made to have that call with -std=c++14 -fno-elide-constructors.

See
https://wg21.link/cwg1631 - CWG1631: Incorrect overload resolution for
single-element initializer-list 
https://wg21.link/cwg1467 - CWG1467: List-initialization of aggregate from
same-type object
https://wg21.link/cwg2137 - CWG2137: List-initialization from object of same
type

Reply via email to