ericmckean / game-music-emu

Automatically exported from code.google.com/p/game-music-emu
GNU Lesser General Public License v2.1
0 stars 0 forks source link

Oveflow? #19

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
gcc complains with

game-music-emu-0.6.0/gme/Spc_Cpu.cpp: In member function 'void 
Snes_Spc::cpu_write_high(int, int, Snes_Spc::rel_time_t)':
game-music-emu-0.6.0/gme/Spc_Cpu.cpp:407:20: warning: array subscript is above 
array bounds [-Warray-bounds]

But since I don't know the emulator so well I can't say for sure if it was 
intended. In any case, perhaps instead of

RAM [i + rom_addr] = cpu_pad_fill; // restore overwritten padding

it could be written as

m.ram.padding2 [i - rom_size] = cpu_pad_fill; // restore overwritten padding

?

That should make the compiler stop complaining. But not sure if it would make 
the code more difficult to understand since... I don't understand it ;-)

Original issue reported on code.google.com by Christia...@gmail.com on 17 Mar 2013 at 10:01

GoogleCodeExporter commented 9 years ago
Something similar applies to

game-music-emu-0.6.0/gme/Spc_Cpu.cpp: In member function 'unsigned int 
Snes_Spc::CPU_mem_bit(const uint8_t*, Snes_Spc::rel_time_t)':
game-music-emu-0.6.0/gme/Spc_Cpu.cpp:473:24: warning: array subscript is below 
array bounds [-Warray-bounds]

But I can't follow the macros. It could or couldn't be a real problem.

Original comment by Christia...@gmail.com on 17 Mar 2013 at 10:11

GoogleCodeExporter commented 9 years ago
I think I managed to reproduce (but not fix) last year, but I just checked with 
both clang 3.4.1 and gcc 4.8.3 and neither warn about array operations here, 
even with "-W -Wall -Wextra" compiler options set.

Probably for the best, since I can't follow the macros either.

Original comment by michael....@gmail.com on 24 Jun 2014 at 12:08