Comment 0 for bug 1818326

Revision history for this message
Tony (tonyk) wrote :

If a 16-bit integer is loaded from memory as a little-endian, and then immediately again as a big-endian, the compiler optimises away the second load, but forgets to switch its endianness. The attached file BigEndianBug.c shows the problem: f2 returns 0x1234 instead of the expected 0x3412.

Incidentally, there is a minor problem in f1 too: the uxth instruction is redundant. (This is still the case at optimisation level O3.)

Compile command:

arm-none-eabi-gcc.exe" -c -oBigEndianBug.o -march=armv6-m -mthumb -Wall -Wa,-a,-adn -O1 BigEndianBug.c >BigEndianBug.lst

Compiler version:

arm-none-eabi-gcc.exe (GNU Tools for Arm Embedded Processors 8-2018-q4-major) 8.2.1 20181213 (release) [gcc-8-branch revision 267074]

Running on Windows 10.