fix UB accessing OOB members of oldreg array
commit3b2642a0e405d12bf186e9a3a3798d9524dc99a2
authorrofl0r <retnyg@gmx.net>
Sun, 26 Nov 2017 22:07:45 +0000 (26 22:07 +0000)
committerrofl0r <retnyg@gmx.net>
Sun, 26 Nov 2017 22:07:45 +0000 (26 22:07 +0000)
tree06dadb43f381fa22dc40c0b6b24c915791b5b3be
parent8f2f8cc38b5a077ba138caafb44d95a402c71e1c
fix UB accessing OOB members of oldreg array

src/thumb.h:26:19: warning: iteration 17 invokes undefined behavior [-Waggressive-loop-optimizations]
        oldreg[xxx]=reg[xxx].I; \
        ~~~~~~~~~~~^~~~~~~~~~~
src/thumb.h:1442:4: note: in expansion of macro 'UPDATE_OLD_REG'
    UPDATE_OLD_REG
    ^~~~~~~~~~~~~~
src/thumb.h:25:7: note: within this loop
       for (xxx=0; xxx<18; xxx++){ \
       ^

according to [0] there are 16 GPRs labelled r0-r15, plus CPSR and SPSR, totalling
to 18. so it was probably an oversight to make the oldreg array only 17 elements
wide.

[0] http://infocenter.arm.com/help/topic/com.arm.doc.ddi0210c/ch02s06s03.html
src/GBA.h
src/Globals.c