Ticket #482 (Fixed)Mon Apr 20 18:00:42 UTC 2020
cc 5.79, 5.80, 5.82: LDRSB is sometimes broken
Reported by: | Jeffrey Lee (213) | Severity: | Major |
Part: | RISC OS: C/C++ toolchain | Release: | |
Milestone: | Status | Fixed |
Details by Jeffrey Lee (213):
When targetting an ARMv4+ CPU, compiler versions 5.79 and newer generate incorrect code when using LDRSB to access an int8_t and convert to int32_t. 5.78 and older appear to be fine.
Although the LDRSB instruction targets the correct memory address, the loaded value is then “ASR #24”’d before it gets used.
This only seems to affect situations where the compiler knows the value is on the stack or has static storage. int8_t’s accessed via arbitrary pointers appear to work correctly.
The attached test case shows a few different situations which either succeed or fail (just compile with ‘-cpu 4’ or higher)
Changelog:
Modified by Jeffrey Lee (213) Mon, April 20 2020 - 18:01:15 GMT
- Attachment added: test
Modified by Sprow (202) Sat, May 02 2020 - 13:53:49 GMT
Using my bookmarked list of magic switches https://groups.google.com/d/msg/comp.sys.acorn….
adding -zpq8 to your CFLAGS appears to dodge the bug.
Modified by Jeffrey Lee (213) Thu, June 04 2020 - 12:22:43 GMT
- Status changed from Open to Fixed
Fixed with DDE29c (cc 5.83)