On Mon, Nov 7, 2011 at 3:43 PM, Jonathan Wakely <jwakely....@gmail.com> wrote:
> This is a new version of my -Wmeminit patch, first posted to PR c++/2972.
>
> Jason suggested combining the Wmeminit warning with the adjacent
> Weffc++ one which I agree with.  The advice in the Effective C++ book
> actually says not to leave members uninitialized, rather than saying
> *all* members must have a mem-initializer (which is just annoying in
> many cases if the type has a safe default constructor), and my patch
> provides a better check for that by only warning when data is left
> uninitialized.
>
> Unfortunately this doesn't work very well in C++11 mode, as defaulted
> constructors don't cause warnings when they should do e.g.
>
> struct C
> {
>  int i;
>  C() = default;
> };
>
> This doesn't produce the same warning as C() {} even though that's
> what the defaulted constructor is equivalent to.

so the defaulted constructor does not initialize C::i?

>
> I'm posting it for comment and in case anyone else has time to work on it.
>
>        * c-family/c.opt (Wmeminit): Add new option.
>        * c-family/c-opts.c: Include it in Wecpp
>        * cp/init.c: Implement Wmeminit.
>        * doc/invoke.texi: document it.
>
>        * testsuite/g++.dg/warn/Wmeminit.C: New.
>

Reply via email to