warning: iteration 2 invokes undefined behavior [-Waggressive-loop-optimizations]
Issue #151
new
I'm getting the following warning when compiling:
===> CXX Build/Tactical/LOS.cc
Build/Tactical/LOS.cc: In function ‘MoveBullet(BULLET*)’:
Build/Tactical/LOS.cc:3856:70: warning: iteration 2 invokes undefined behavior [-Waggressive-loop-optimizations]
if ( gubWorldMovementCosts[ iAdjGridNo ][ sDesiredLevel ][ bDir ] < TRAVELCOST_BLOCKED)
^
Build/Tactical/LOS.cc:3852:5: note: containing loop
for( bDir = 0; bDir < NUM_WORLD_DIRECTIONS; bDir++)
^
From the declaration of gubWorldMovementCosts (Build/TileEngine/WorldDef.h:225) and the values assigned to the index variables I think line 3856 should be
if ( gubWorldMovementCosts[ iAdjGridNo ][ bDir ][ sDesiredLevel ] < TRAVELCOST_BLOCKED)
I have not checked what implications the change has on the code semantics.