[Bug c++/50965] New: C++11 Non static member initializer are not run when class is initialized with {}

ogoffart at kde dot org gcc-bugzilla@gcc.gnu.org
Wed Nov 2 17:31:00 GMT 2011


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

             Bug #: 50965
           Summary: C++11 Non static member initializer are not run when
                    class is initialized with {}
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: ogoffart@kde.org


Using g++ (GCC) 4.7.0 20111031 (experimental)


struct A { int i = 42; };
int main() {
   A a{};
   std::cout << a.i << std::endl; // shows 0
   std::cout << A{}.i << std::endl; // shows 0
}



More information about the Gcc-bugs mailing list