[PATCH] Fix for bug 11684
Ralph Boehme
rb at sernet.de
Thu Jan 21 21:48:06 UTC 2016
On Thu, Jan 21, 2016 at 01:06:37PM -0800, Jeremy Allison wrote:
> On Thu, Jan 21, 2016 at 09:25:53PM +0100, Michael Adam wrote:
> > On 2016-01-21 at 20:50 +0100, Volker Lendecke wrote:
> > > On Thu, Jan 21, 2016 at 08:45:42PM +0100, Ralph Boehme wrote:
> > > > > {} is non-standard, other compilers will not accept this.
> > > >
> > > > We use it all over the place.
> > >
> > > Ok, sorry for the noise. We should go through and convert
> > > all the {0} that we already have to {}. We should at least
> > > be consistent.
> >
> > From a quick git grep, we seem to use
> >
> > - { 0 } in 91 places
> > - { 0, } in 72 places
> > - { } in 7 places
> >
> > So yes, we should systematize, but probably not to {} ... :-)
>
> 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.
-Ralph
--
SerNet GmbH, Bahnhofsallee 1b, 37081 Göttingen
phone: +49-551-370000-0, fax: +49-551-370000-9
AG Göttingen, HRB 2816, GF: Dr. Johannes Loxen
http://www.sernet.de,mailto:kontakt@sernet.de
More information about the samba-technical
mailing list