This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch] Add a new warning flag -Wself-assign


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]