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

            Bug ID: 88875
           Summary: [8 regression] initializer_list and explicit ctor
           Product: gcc
           Version: 9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: nathan at gcc dot gnu.org
  Target Milestone: ---

Created attachment 45440
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=45440&action=edit
testcase

We reject default member list initializers when the member has an explicit ctor
taking a list.  We accept such an initialier on an explicit member initializer.

GCC-8 accepted this.

g++ -std=c++17 -c gb.cc -save-temps
gb.cc:10:14: error: converting to 'X' from initializer list would use explicit
constructor 'X::X(const std::initializer_list<int>&)'
   10 |   X x { 1, 2 }; // error


member initialization is direct-initialization:
The expression-list or braced-init-list in a mem-initializer is used to
initialize the designated subobject (or, in the case of a delegating
constructor, the complete class object) according to the initialization rules
of 9.3 for direct-initialization. [class.base.init]/7

/copy/-list-initialization prohibits resolving to an explicit-ctor:
In copy-list-initialization, if an explicit constructor is chosen, the
initialization is ill-formed. [over.match.list]/2

but there's no such restriction for direct initialization.

Reply via email to