[Bug c++/81431] add warning for missing initializers in constructor

egallager at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Tue Aug 22 22:43:00 GMT 2017


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81431

Eric Gallager <egallager at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
                 CC|                            |egallager at gcc dot gnu.org
         Resolution|---                         |DUPLICATE

--- Comment #2 from Eric Gallager <egallager at gcc dot gnu.org> ---
(In reply to Tom Tromey from comment #0)
> I would like gcc to emit a warning when a constructor does not
> initialize a POD member; and in particular I'd like this not to
> be tied to -Wuninitialized.
> 
> Having a warning like this is good for robustness -- it avoids
> situations where one forgets to initialize a scalar or the like.
> 
> I realize -Wuninitialized will do this, but that can be a difficult
> warning to enable for an existing code base, due to false positives.
> 
> Something along the lines of
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=2972#c9
> would be nice.
> 
> -Weffc++ does warn about this, but it is too broad, as it includes
> members that have a constructor.

-Weffc++ being too broad is bug 16166.

> 
> Here's a simple example:
> 
> struct X
> {
>   int a,b;
> 
>   X() : a(5) { }
> };
> 
> X x;

*** This bug has been marked as a duplicate of bug 16166 ***


More information about the Gcc-bugs mailing list