This is the mail archive of the gcc-bugs@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]

[Bug c++/62182] New warning wished: operator== and "equality comparison result unused [-Wunused-comparison]"/-Wunsed-value


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.


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