This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/55805] New: Empty brace-init-list causes warning "missing initializer for member" in C++11


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: unassigned@gcc.gnu.org
        ReportedBy: moritz@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).


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]