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

            Bug ID: 60416
           Summary: [4.9 Regression] aggregate init will not use explicit
                    default constructors for members with no
                    initializer-clause
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Keywords: rejects-valid
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: redi at gcc dot gnu.org
                CC: jason at gcc dot gnu.org

I think the fix for PR 54835 went too far, so that the following is now
rejected:

struct A {
  explicit A() { }
};

struct B {
  A a;
};

B b = { };


k.cc:9:9: error: converting to ‘A’ from initializer list would use explicit
constructor ‘A::A()’
 B b = { };
         ^

This breaks some valid C++03 programs.

[dcl.init.aggr]/7 has an example indicating that b.a should be initialized with
A{}, which should be able to call an explicit constructor.

The code above is accepted by clang.

N.B. I believe this should still be rejected, which agrees with the suggested
direction of DR 1518:

B b2 = { {} };

Reply via email to