[llvm-bugs] [Bug 32156] New: Should = { 0 }; fire -Wmissing-braces in C99?
via llvm-bugs
llvm-bugs at lists.llvm.org
Mon Mar 6 13:23:13 PST 2017
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: unassignedclangbugs at nondot.org
Reporter: gpakosz at pempek.net
CC: llvm-bugs at 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20170306/b5ebf899/attachment.html>
More information about the llvm-bugs
mailing list