https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103067

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2021-11-03
     Ever confirmed|0                           |1

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
The warning could be smarter and assume that operator== has the usual
semantics, and therefore 'age == age' would warn, even though *in theory* the
operator== could do something meaningful when called like that. But in
practice, warning would be helpful a lot more often than anybody writes weird
operator== definitions where 'age == age' is actually what the developer meant
to write. 99.999% of operator== functions do what you expect, and so 'age ==
age' is probably a mistake and should warn.

Related to that, it would be nice if calls to operator== functions also gave
-Wunused-value warnings, like the built-in == for scalars. Again, 99.999% of
operator== functions have no side effects and are only called for the result,
so if it's unused, the compiler should warn.

Reply via email to