gccc-preprocessorarmcc

GCC ARM preprocessor computes wrong negative number


This question relates to arm-none-eabi-gcc version 5.4.1. (I know is rather old but I must use it).

int32_t tmp = INT32_MIN / 2;

This produces the following assembly:

mov.w   r3, #1073741824 ; 0x40000000

When looking at this macro in stdint.h:

#define INT32_MIN        (-0x80000000)

Is Correct.

The debugger also shows positive number which corresponds to 0x40000000.

I would expect 0xC0000000.

Is this a bug of that particular gcc preprocessor or is it normal?


Solution

  • Is a bug, GCC 6.3.0 preprocessor performs normally.

    Tried to find out more on https://gcc.gnu.org/bugzilla/buglist.cgi but there are so many reported bugs that I did not succeed...