This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/62182] New warning wished: operator== and "equality comparison result unused [-Wunused-comparison]"/-Wunsed-value
- From: "arnaud.bienner at ensimag dot fr" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 15 Apr 2015 22:40:22 +0000
- Subject: [Bug c++/62182] New warning wished: operator== and "equality comparison result unused [-Wunused-comparison]"/-Wunsed-value
- Auto-submitted: auto-generated
- References: <bug-62182-4 at http dot gcc dot gnu dot org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62182
--- Comment #3 from Arnaud Bienner <arnaud.bienner at ensimag dot fr> ---
Created attachment 35324
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=35324&action=edit
unused-comparison warning
I also believe it can be useful to have "unused comparison" warning (i.e.
something more specific than current "unused value" warning, because they are
likely to be typo.
Having a dedicated warning will allow people who want to activate this warning
specifically and/or to turn it into an error.
So I started to have a look at this and I would like to have some feedback from
someone more experienced.
It's my first patch to gcc, so it is probably not perfect.
One thing that doesn't work is turning on this warning using
-Wunused-comparison parameter. But surprisingly, turning it off with
-Wno-unused-comparison (when -Wunused or -Wall is used) works. Not sure what
I'm missing here.
The patch would just be a first step: the next step would be to also raise this
warning in the case of a "==" operator overloading in C++ (which seems to be
the case that doesn't raise a warning currently). Not sure yet how to do this.