https://bugs.llvm.org/show_bug.cgi?id=32156
Bug ID: 32156
Summary: Should = { 0 }; fire -Wmissing-braces in C99?
Product: clang
Version: 3.9
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: Frontend
Assignee: unassignedclangb...@nondot.org
Reporter: gpak...@pempek.net
CC: llvm-bugs@lists.llvm.org
Hello,
I noticed GCC and clang behave differently regarding -Wmissing-braces.
In C99, I'm wondering whether "= { 0 };" should warn when initializing a struct
defined with another struct as member and so on and so forth.
For example, https://godbolt.org/g/WLySA2
struct Bar
{
int i;
};
struct Foo
{
struct Bar bar;
};
int main(int argc, char* argv[])
{
//struct Foo foo = { { 0 } };
struct Foo foo = { 0 };
return foo.bar.i;
}
Would struct Bar contain another struct Baz, then I would need to initialize
foo with 3 levels of nested braces. However, when initializing struct Foo, all
that matters is that it all gets initialized to 0. I don't believe I should
have to jump from header to header to figure out the number of nested braces I
need to use or that I should be brute-force adding levels of { } until the
compiler stops complaining.
Also, contrary to clang, it seems recent GCC versions stopped emitting
-Wmissing-braces when one writes = { 0 };
What do you think?
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs