Modulo operator broken on uint64_t
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
GNU Arm Embedded Toolchain |
Invalid
|
High
|
Unassigned |
Bug Description
Modulo operator '%' seems to be broken on uint64_t.
The following code crashes the MCU and put's me into the reset handler.
Simply switching uint64_t to uint32_t and it works.
int main(void) {
int64_t j = 0;
for (j = 0; j < 10000; j++) {
if (j % 1000 == 0) {
}
}
}
Compile options:
arm-none-eabi-gcc -mthumb -mcpu=cortex-m3 -mfloat-abi=softfp -ffunction-sections -fdata-sections -Os -flto -fno-exceptions -c -g -Ilibopencm3/
mkdir -p dist/Debug/
Linker options:
arm-none-eabi-gcc -mthumb -mcpu=cortex-m3 -mfloat-abi=softfp -ffunction-sections -fdata-sections -Os -flto -fno-exceptions -o dist/Debug/
Linker script was used from libopencm3 for stm32f103rbt6 (included in the example code)
I've attached a code example modulo-bug.tar.bz2
Compiler used:
Binary package gcc-arm-
arm-none-eabi-gcc (GNU Tools for ARM Embedded Processors) 5.4.1 20160919 (release) [ARM/embedded-
host machine:
$ uname -a
Linux wrkst01 3.16.0-4-amd64 #1 SMP Debian 3.16.36-1+deb8u1 (2016-09-03) x86_64 GNU/Linux
$ cat /etc/debian_version
8.6
target machine:
Olimex Olimexino-STM32 (STM32F103RBT6)
With best Regards
Heiko Jakob
Changed in gcc-arm-embedded: | |
status: | New → Confirmed |
importance: | Undecided → High |
Hi Heiko,
Why are you passing -mfloat-abi=softfp? The Cortex-M3 does not support Floating-Point Extensions.
This combination of options leads to the selection of our default multilib which was build for ARMv4T which supports ARM code and this is why you are getting a ldivmod implementation in ARM mode. Which obviously will not run for a Cortex-M3.
Pass either -mfloat-abi=soft or just leave out the -mfloat-abi option altogether, which defaults to 'soft'.
Best Regards,
Andre