[Bug c/105581] boolean types and relational operators problem
dcb314 at hotmail dot com
gcc-bugzilla@gcc.gnu.org
Thu May 12 11:49:45 GMT 2022
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105581
--- Comment #3 from David Binderman <dcb314 at hotmail dot com> ---
(In reply to Andrew Pinski from comment #1)
> Well. There is a meaning for the code though.
> That is negative > other_negative
> Means negative is true while other_negative is false the result will be true
> which is exactly what it is testing here.
In abstract, false and true can't be compared with "<".
In the implementation choice of false as 0 and true as 1, then relying
on the implementation values does make "<" valid.
I think that's the bad style cppcheck is complaining about. It's just
better style to have it as a logical expression, as Andreas shows.
More information about the Gcc-bugs
mailing list