This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/55805] New: Empty brace-init-list causes warning "missing initializer for member" in C++11
- From: "moritz at bunkus dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 25 Dec 2012 12:25:56 +0000
- Subject: [Bug c++/55805] New: Empty brace-init-list causes warning "missing initializer for member" in C++11
- Auto-submitted: auto-generated
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).