fix aggressive loop optimizations
Previously, aggressive loop optimizations with a new compiler were not possible due to undefined behaviour at end of arrays. A macro "UBFIX" is added to allow ifdefs for fixes which resolve undefined behavior. For example newer GCC versions will detect various bugs in the original game code and will otherwise not compile with -Werror.
This commit is contained in:
@@ -533,9 +533,16 @@ static bool32 SavedMapViewIsEmpty(void)
|
||||
u16 i;
|
||||
u32 marker = 0;
|
||||
|
||||
#ifndef UBFIX
|
||||
// BUG: This loop extends past the bounds of the mapView array. Its size is only 0x100.
|
||||
for (i = 0; i < 0x200; i++)
|
||||
marker |= gSaveBlock1Ptr->mapView[i];
|
||||
#else
|
||||
// UBFIX: Only iterate over 0x100
|
||||
for (i = 0; i < ARRAY_COUNT(gSaveBlock1Ptr->mapView); i++)
|
||||
marker |= gSaveBlock1Ptr->mapView[i];
|
||||
#endif
|
||||
|
||||
|
||||
if (marker == 0)
|
||||
return TRUE;
|
||||
|
||||
Reference in New Issue
Block a user