From aa97afffb4c44ff3173ef2b431918345290abd65 Mon Sep 17 00:00:00 2001 From: Alejandro Javier Asenjo Nitti Date: Tue, 16 Apr 2024 00:14:12 -0300 Subject: [PATCH] fix GCC UB with audio (finally) --- Makefile | 2 +- include/sf64audio_provisional.h | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 9e609098..9fa39d99 100644 --- a/Makefile +++ b/Makefile @@ -339,7 +339,7 @@ build/src/libultra/os/%.o: OPTFLAGS := -Os build/src/libultra/rmon/%.o: OPTFLAGS := -Os build/src/libultra/debug/%.o: OPTFLAGS := -Os build/src/libultra/host/%.o: OPTFLAGS := -Os -build/src/audio/audio_load.o: OPTFLAGS := -Os # Crashes with -O2 and -O3 +build/src/audio/audio_load.o: OPTFLAGS := -O2 build/src/audio/%.o: OPTFLAGS := -O2 -g # per-file flags diff --git a/include/sf64audio_provisional.h b/include/sf64audio_provisional.h index 48d96686..cd9e95ed 100644 --- a/include/sf64audio_provisional.h +++ b/include/sf64audio_provisional.h @@ -793,7 +793,11 @@ typedef struct { /* 0x02 */ s16 unkMediumParam; /* 0x04 */ u32 romAddr; /* 0x08 */ char pad[0x8]; + #ifdef AVOID_UB + /* 0x10 */ AudioTableEntry entries[]; // (dynamic size) + #else /* 0x10 */ AudioTableEntry entries[1]; // (dynamic size) + #endif } AudioTable; // size >= 0x20 typedef struct SampleDma {