BrogueCE
BrogueCE copied to clipboard
Another Priority Issue of && and II
There is a compiler warning in Items.c
boolean polymorph(creature *monst) {
...
if (monst->creatureState == MONSTER_FLEEING
&& (monst->info.flags & (MONST_MAINTAINS_DISTANCE | MONST_FLEES_NEAR_DEATH)) || (monst->info.abilityFlags & MA_HIT_STEAL_FLEE)) {
...
Place parentheses around the '&&' expression to silence this warning
Based on the compiler default priority, the code is equal to
if ((monst->creatureState == MONSTER_FLEEING && (monst->info.flags & (MONST_MAINTAINS_DISTANCE | MONST_FLEES_NEAR_DEATH)))
|| (monst->info.abilityFlags & MA_HIT_STEAL_FLEE)) {
But I thought it should be
if (monst->creatureState == MONSTER_FLEEING
&& ((monst->info.flags & (MONST_MAINTAINS_DISTANCE | MONST_FLEES_NEAR_DEATH))
|| (monst->info.abilityFlags & MA_HIT_STEAL_FLEE))) {
...
Is this a bug?