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;

Reply via email to