This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/36921] [4.3/4.4 Regression] warning "comparison does not have mathematical meaning" is not correct for overloaded operators that do not return boolean
- From: "deba at inf dot elte dot hu" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 3 Dec 2008 19:26:20 -0000
- Subject: [Bug c++/36921] [4.3/4.4 Regression] warning "comparison does not have mathematical meaning" is not correct for overloaded operators that do not return boolean
- References: <bug-36921-16097@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #9 from deba at inf dot elte dot hu 2008-12-03 19:26 -------
(In reply to comment #8)
> I'm not convinced that we shouldn't warn in these cases. Yes, there are cases
> where people overload the operators in ways that make normal precedence
> irrelevant. But, there are also cases where people define boolean-like objects
> that are not themselves "bool".
>
If the user-defined boolean-like object can be compared with other types, then
the user had to write such a comparison operator, therefore the user declared
that the boolean-like type is comparable with the other type. So this case
could not be a problem.
However, in my point of view, the proposed patch is not surely the best
solution. The C++ defined the bool, which could solve the (a < b < c) problem.
But unfortunately, as a shortcoming of the backward compatibility with C, the
bool type is convertible to numeric types, which is a quite wrong pitfall. I
think, instead of the current patch, the implicit conversion of a bool to
numeric value should be warned in C++.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36921