Re: [igt-dev] [PATCH i-g-t] meson: add -Wno-missing-braces

Ser, Simon
2019-03-21T07:25:23Z

On Wed, 2019-03-20 at 14:22 +0200, Petri Latvala wrote:
> On Wed, Mar 20, 2019 at 02:11:16PM +0200, Jani Nikula wrote:
> > On Wed, 20 Mar 2019, "Ser, Simon" <simon.ser@intel.com> wrote:
> > > On Wed, 2019-03-20 at 11:38 +0200, Jani Nikula wrote:
> > > > On Wed, 20 Mar 2019, "Ser, Simon" <simon.ser@intel.com> wrote:
> > > > > Enabling -Werror=missing-braces results in this error with
> > > > > Clang:
> > > > >
> > > > > ../tests/kms_vrr.c:203:20: error: suggest braces around
> > > > > initialization of subobject [-Werror,-Wmissing-braces]
> > > > > drmVBlank vbl = { 0 };
> > > > > ^
> > > > > {}
> > > > >
> > > > > I don't believe there is any value in keeping this, so let's
> > > > > just
> > > > > disable it.
> > > >
> > > > I fail to come up with examples right now, but I think there
> > > > are
> > > > legitimate cases for the warning.
> > > >
> > > > Arguably the above initializer should be written as simply {}
> > > > instead
> > > > of
> > > > having the 0 value for initializing the first member which
> > > > happens to
> > > > be
> > > > a substruct.
> > >
> > > Unfortunately using {} is a GNU extension, and ISO C forbids
> > > empty
> > > initializer lists.
> >
> > Right, it's also okay in ISO C++11.
> >
> > > Does IGT use un-standardized extensions?
> >
> > I'm pretty sure it does, but I'll defer decisions about this to the
> > IGT
> > maintainers.
>
> We use -std=gnu11.
>
> It's not as an explicit flag anywhere, making it hard to find. It's
> in
> toplevel meson.build, the project() call, default_options:
> 'c_std=gnu11'

All right! It's probably fine to use this extension then.

(I personally prefer to stick to ISO C and POSIX, but the project
preference prevails of course!)

> A quick look in autotools reveals that we don't set the std on it at
> all. Oh well.