This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [patch] Add a new warning flag -Wself-assign
- From: Andrew Pinski <pinskia at gmail dot com>
- To: Le-Chun Wu <lcwu at google dot com>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>, Diego Novillo <dnovillo at google dot com>
- Date: Fri, 28 May 2010 16:52:46 -0700
- Subject: Re: [patch] Add a new warning flag -Wself-assign
- References: <AANLkTimzSEcPPEePxoXu1eL_CwUmCFlhz8riqIy4w614@mail.gmail.com>
On Fri, May 28, 2010 at 4:47 PM, Le-Chun Wu <lcwu@google.com> wrote:
> As mentioned above, this flag warns about self-initialization as well.
> Unlike the existing Â-Winit-self flag, this new flag does not require
> the use of -Wuninitialized.
Well I think we should not warn about local variables with this option
because that was designed to get rid of the uninitialized warning.
The reason why I mention this is because -Wuninitialized is now
supported at -O0.
> Â Â Â Âclass Foo {
> Â Â Â Â private:
> Â Â Â Â Âint a_;
>
> Â Â Â Â public:
> Â Â Â Â ÂFoo() : a_(a_) {} // warns with -Wself-assign, but not with
> -Winit-self
> Â Â Â Â};
I think the above should warn under a different flag and it is
recorded as http://gcc.gnu.org/PR18016 .
I think this warning (except for auto variables) should be turned on with -Wall.
Thanks,
Andrew Pinski