[vlc-devel] [PATCH 3/3] configure: add -Werror=missing-field-initializers option to the compiler
ajanni at videolabs.io
Wed Dec 18 10:24:27 CET 2019
On Wed, Dec 18, 2019 at 09:19:17AM +0100, Steve Lhomme wrote:
> On 2019-12-17 18:22, Rémi Denis-Courmont wrote:
> > Le tiistaina 17. joulukuuta 2019, 16.09.29 EET Steve Lhomme a écrit :
> > > This avoids leaving some fields initialized in structures that require
> > > initialization (like in the video context operations). It's always better to
> > > set NULL (with a TODO/FIXME is needed) explicitly than forget it.
> > >
> > > Compound literal designated initializers are not affected.
> > That's great but designated initializers don't work in C++, or in common C/C++
> Then don't use such initializers in C++ code.
I think care have been taken to avoid using it in headers,
like for vlc_vector.h for example. There might be other leaks
in the code though.
> > headers, and more generally, perfectly valid code that just wants to
> > initialize values to the default nul.
> It's better to explicitly set NULL for a callback IMO than not paying
> attention at all in code you don't know about. That will only be found in
> the bots if we can detect such missed code change early.
I don't agree with that, although it highlights very long
structures like player callbacks in C++ code.
I don't think we should avoid using them when it makes sense.
Non-designated initializers might even raise order issues
with compatible pointers.
We should probably use designated initializer in C++ code
when C++17 standard will be accepted, as it enforces what
you really want in C++ code.
> > This does not belong as an error. Denis and I have already made the exact same
> > point not that long ago.
> How about an option to force extra compilation checks ?
Why not, but I really feel that this option should not be
part of it.
More information about the vlc-devel