This is a very weird one for me.
The gcc compiler generates correct code, but it does it in an inexplicably weird way.
Say I have a pointer in memory, say 0x98fa, declare as a readonly array of pointers (so it's in flash).
I want to index this array, like char * something = motor_map[n]
I would expect the compiler to multiply n by the size of a pointer (e.g. 2) and then add the address of the array.
It actually *subtracts* the 2's complement negative value of the array pointer.
So it's effectively subtracting 0x6706 from the offset (?!). This causes an overflow, of course, then returns the correct result.
Why would it do this?