|
|
The following is an excerpt from express.c
(MegaPov 0.6a, lines 505 and below):
if( hfield->Type & HFIELD_OBJECT != HFIELD_OBJECT )
Error( "Cannot find height of non-height-field.\n" );
if( ( Val < 0 ) || ( Val2 < 0 ) ||
( Val > 1 ) || ( Val2 > 1 ) )
Error( "Height-field index out of bounds [0 1].\n" );
Since the precedence of 'not equal' is higher than that
of 'bitwise and', the very first line really means
if( hfield->Type & 0 )
and thus the error message never appears. In fact,
optimizing compilers eliminate entire statement. I
quoted a little bit more than necessary just to illustrate
(and rant :-) how... unwise people use parentheses.
BTW (to those who are interested): this strange
precedence rule goes deep into the history of C...
From the very beginning, there were no such things
as 'logical and' and 'logical or' (that is, '&&' and '||'),
the only 'and' and 'or' operators were '&' and 'I',
respectively, serving as either logical or bitwise
based upon context ("truth-value-context"). When
their "pure logical" counterparts were introduced,
K&R were forced to stick with their current
precedence to maintain compatibility with existing
code.That's that.
Post a reply to this message
|
|