[PATCH] Fix for bug 11684

Jeremy Allison jra at samba.org
Thu Jan 21 21:59:15 UTC 2016


On Thu, Jan 21, 2016 at 10:48:06PM +0100, Ralph Boehme wrote:
> On Thu, Jan 21, 2016 at 01:06:37PM -0800, Jeremy Allison wrote:
> > As I recall, the (broken) gcc version we have wants a sub-{}
> > for every internal struct inside the struct we're initializing.
> > That correct ?
> 
> Not quite. It wants a sub {} when the first member is of complex type.
> 
> The gcc version doesn't suffer from this anymore so I didn't spot the
> issue.
> 
> $ cat ~/files/test.c
> struct foo {
>         char c[2];
>         int i;
> };
> 
> struct bar {
>         int i;
>         char c[2];
> };
> 
> struct struct1 {
>         struct foo foo;
>         int i;
> };
> 
> struct struct2 {
>         int i;
>         struct foo foo;
> };
> 
> int main(int argc, char **rgv)
> {
>         struct foo foo = { 0 };
>         struct bar bar = { 0 };
>         struct struct1 struct1 = { 0 };
>         struct struct2 struct2 = { 0 };
> 
>         return 0;
> }
> 
> $ gcc --version
> gcc (GCC) 5.3.1 20151207 (Red Hat 5.3.1-2)
> Copyright (C) 2015 Free Software Foundation, Inc.
> This is free software; see the source for copying conditions.  There is NO
> warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
> 
> $ gcc -Wmissing-braces /home/ralph/files/test.c -o test
> $
> 
> On sn-devel144:
> 
> $ gcc --version
> gcc-4.8.real (Ubuntu 4.8.4-2ubuntu1~14.04) 4.8.4
> Copyright (C) 2013 Free Software Foundation, Inc.
> This is free software; see the source for copying conditions.  There is NO
> warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
> 
> $ gcc -Wmissing-braces -o test test.c
> test.c: In function ‘main’:
> test.c:23:10: warning: missing braces around initializer [-Wmissing-braces]
>    struct foo foo = { 0 };
>           ^
> test.c:23:10: warning: (near initialization for ‘foo.c’) [-Wmissing-braces]
> test.c:25:10: warning: missing braces around initializer [-Wmissing-braces]
>    struct struct1 struct1 = { 0 };
>           ^
> test.c:25:10: warning: (near initialization for ‘struct1.foo’) [-Wmissing-braces]
> 
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53119
> 
> Backports of the fix are available but apparently not included in the
> Ubuntu version.
> 
> Imho we should for now just use {}, it seems all relevent compiler
> support this non-standard form.

Thanks for doing the tests. Nothing like facts in a
heated debate :-).

Unfortunately 14.04 is a LTS version, so this damn
bug will be around for a while.

Volker, is {} for new code acceptible for you ?

Eventually we'll be able to have a flag day and
do {} -> { 0 }.



More information about the samba-technical mailing list