Consider this being compiled in MS Visual Studio 2005 (and probably others):
CPoint point1( 1, 2 );
CPoint point2( 3, 4 );
const bool point1And2Identical( point1 == point2 ); // C4800 warning
const bool point1And2TheSame( ( point1 == point2 ) == TRUE ); // no warning
What the...? Is the MSVC compiler brain-dead? As far as I can tell, TRUE is #defined as 1, without any type information. So by what magic is there any difference between these two lines? Surely the type of the expression inside the brackets is the same in both cases? [This part of the question now satisfactorily answered in the comments just below]
Personally, I think that avoiding the warning by using the == TRUE option is ugly (though less ugly than the != 0 alternative, despite being more strictly correct), and it is better to use #pragma warning( disable:4800 ) to imply "my code is good, the compiler is an ass". Agree?
Note - I have seen all manner of discussion on C4800 talking about assigning ints to bools, or casting a burger combo with large fries (hold the onions) to a bool, and wondering why there are strange results. I can't find a clear answer on what seems like a much simpler question... that might just shine line on C4800 in general.
operator==
related to classCPoint
. – aschepler==
results in abool
, not aBOOL
. – aschepler