This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/81431] add warning for missing initializers in constructor
- From: "egallager at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 22 Aug 2017 20:25:41 +0000
- Subject: [Bug c++/81431] add warning for missing initializers in constructor
- Auto-submitted: auto-generated
- References: <bug-81431-4@http.gcc.gnu.org/bugzilla/>
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 ***