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:
Michael Panzlaff
2020-05-09 14:49:51 +02:00
parent 46f4a4bbf7
commit 3264cf697f
10 changed files with 79 additions and 45 deletions

View File

@@ -26,4 +26,12 @@
#define UNITS_METRIC
#endif
// Various undefined behavior bugs may or may not prevent compilation with
// newer compilers. So always fix them when using a modern compiler.
#if MODERN
#ifndef UBFIX
#define UBFIX
#endif
#endif
#endif // GUARD_CONFIG_H

View File

@@ -18,6 +18,13 @@ typedef union // size = 0x24
/*0x23*/ u8 trainerIdHi;
} common;
// Common init (used for initialization loop)
struct {
/*0x00*/ u8 kind;
/*0x01*/ bool8 active;
/*0x02*/ u8 pad02[34];
} commonInit;
// Local shows
// TVSHOW_FAN_CLUB_LETTER
struct {