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



             Bug #: 55805

           Summary: Empty brace-init-list causes warning "missing

                    initializer for member" in C++11

    Classification: Unclassified

           Product: gcc

           Version: 4.7.2

            Status: UNCONFIRMED

          Severity: normal

          Priority: P3

         Component: c++

        AssignedTo: unassig...@gcc.gnu.org

        ReportedBy: mor...@bunkus.org





The C++11 standard has this to say on empty brace-init-lists in 8.5.4.3:



  " If the initializer list has no elements and T is a class type with a

default constructor, the object is value-initialized."



However, g++ issues a warning with "-Wmissing-field-initializers" (which is

included in "-Wextra"). Example:



class A {

public:

  int f;

};



int

main() {

  A a3{};

  return 0;

}



Compile with "g++ -Wextra -std=c++11 -o test1 test1.cpp"



clang++ 3.1 does not emit that warning. g++ 4.6, 4.7 and 4.7.2 do (those are

the ones I have available here).

Reply via email to