This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/81431] New: add warning for missing initializers in constructor
- From: "tromey at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 13 Jul 2017 17:30:42 +0000
- Subject: [Bug c++/81431] New: add warning for missing initializers in constructor
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81431
Bug ID: 81431
Summary: add warning for missing initializers in constructor
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: tromey at gcc dot gnu.org
Target Milestone: ---
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.
Here's a simple example:
struct X
{
int a,b;
X() : a(5) { }
};
X x;