Invalid code generation at high optimization level
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
GNU Arm Embedded Toolchain |
Invalid
|
Undecided
|
Unassigned |
Bug Description
Invalid code generated at optimization level >= -O2.
Generated code may be reviewed from assembly output:
---------------
ldr r3, [r3, #36] @ dhcp_rx_
mov r1, r4 @, tmp1173
rev r3, r3 @ D.6523, dhcp_rx_options_val
movs r0, #1 @,
str r3, [sp, #36] @ D.6523, dns_addr.addr
bl dns_setserver @
.L334:
ldr r1, [r3, #48] @ D.6532, dhcp_37-
b .L335 @
.L332:
---------------
At label .L334 'r3' register does not points to 'dhcp_37' anymore ('dhcp' variable in C code). This causes crash on Cortex-M3 (MPU enabled to track NULL accesses (first 4KB region)).
Host: Mac OS
gcc version: arm-none-eabi-gcc (GNU Tools for ARM Embedded Processors) 5.4.1 20160919 (release) [ARM/embedded-
Invocation: arm-none-eabi-gcc -mthumb -mcpu=cortex-m3 -I. -S -fverbose-asm -O3 dhcp.c
summary: |
- Invalid core generation at high optimization level + Invalid code generation at high optimization level |
Changed in gcc-arm-embedded: | |
status: | New → Invalid |
This place may be found by searching for 2nd occurrence of 'dns_setserver' referencing (assembly output).