0

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?

tk_
  • 490
  • 3
  • 15
  • `(-0x80000000) Is Correct.` What standard library are you using? It's https://github.com/eblot/newlib/blob/master/newlib/libc/include/stdint.h#L296 this in newlib. Does `(-2147483647L-1) / 2` result in the same? – KamilCuk Feb 04 '22 at 11:11

1 Answers1

0

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...

tk_
  • 490
  • 3
  • 15