[Bug c++/54835] New: [C++11] Explicit default constructors not respected during copy-list-initialization

daniel.kruegler at googlemail dot com gcc-bugzilla@gcc.gnu.org
Sat Oct 6 11:20:00 GMT 2012


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54835

             Bug #: 54835
           Summary: [C++11] Explicit default constructors not respected
                    during copy-list-initialization
    Classification: Unclassified
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: daniel.kruegler@googlemail.com


gcc 4.8.0 20120930 (experimental) with the compiler flags

-Wall -pedantic -std=c++11 

accepts the following copy-list-initialization of a class type with an explicit
default constructor:

//-------------------------
struct S {
  explicit S(int = 0) {}
};

S s = {};
//-------------------------

This code should be ill-formed, because it is ruled out by [over.match.list],
in particular by the unconditional wording:

"In copy-list-initialization, if an explicit constructor is chosen, the
initialization is ill-formed."



More information about the Gcc-bugs mailing list