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: Wed, 9 Jun 2010 11:32:40 -0700
- Subject: Re: [patch] Add a new warning flag -Wself-assign
- References: <AANLkTimzSEcPPEePxoXu1eL_CwUmCFlhz8riqIy4w614@mail.gmail.com> <AANLkTin4pwHaYM6g3YGs-SnDrYt_S-j5o1whklh-hjVO@mail.gmail.com> <AANLkTilN-qojdwcRMfU8wCv34u-yUPtjSWBIidQLcqSt@mail.gmail.com>
On Wed, Jun 9, 2010 at 11:25 AM, Le-Chun Wu <lcwu@google.com> wrote:
> It should be pretty easy to modify this patch to not warn about
> self-initialization of local variables with this flag. However, what I
> don't understand is why a user would want to work around (or suppress)
> an uninitialized warning by doing self-initialization. They could have
> just initialized a local variable to some other more meaningful value.
> Initializing a variable with itself doesn't seem like a good way to
> fix an uninitialized warning.
Well this is the documented way of disabling the warning. If we want
to change this, we should get rid of -Winit-self at the same time.
And remove the documentation for this special case. I don't remember
the full history behind my change of the documentation to mention this
special case but from what I remember the source at one point did not
warn about "int t = t +1;". And that I was fixing that case with
keeping the special case of "int i = i;".
Thanks,
Andrew Pinski