From eb7492c6c6ffba0796f7bdd704f78a2c8eced7be Mon Sep 17 00:00:00 2001 From: nattthebear Date: Sun, 16 Jul 2017 21:08:07 -0400 Subject: [PATCH] Fix undefined behavior (sequence point modification). GCC 4.6.4 compiles the code incorrectly without this fix. --- Core/z80_cpu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Core/z80_cpu.c b/Core/z80_cpu.c index 0a1bde5..6ea6a38 100644 --- a/Core/z80_cpu.c +++ b/Core/z80_cpu.c @@ -283,7 +283,7 @@ static void jr_r8(GB_gameboy_t *gb, uint8_t opcode) { /* Todo: Verify cycles are not 8 and 4 instead */ GB_advance_cycles(gb, 4); - gb->pc += (int8_t) GB_read_memory(gb, gb->pc++); + gb->pc += (int8_t)GB_read_memory(gb, gb->pc) + 1; GB_advance_cycles(gb, 8); } @@ -307,7 +307,7 @@ static void jr_cc_r8(GB_gameboy_t *gb, uint8_t opcode) { if (condition_code(gb, opcode)) { GB_advance_cycles(gb, 4); - gb->pc += (int8_t)GB_read_memory(gb, gb->pc++); + gb->pc += (int8_t)GB_read_memory(gb, gb->pc) + 1; GB_advance_cycles(gb, 8); } else {