Ticket #517 (Open)Fri Jun 25 18:53:59 UTC 2021
cc 5.86: Inlined code calculates wrong result
Reported by: | Jeffrey Lee (213) | Severity: | Major |
Part: | RISC OS: C/C++ toolchain | Release: | |
Milestone: | Status | Open |
Details by Jeffrey Lee (213):
In aborttrapinstr.h, if you set ABORTTRAP_INLINE to 0 then everything’s fine, and you’ll get this output when running the code:
46e5c2c0 00000018 11 3
If you set ABORTTRAP_INLINE to 1 then you’ll get this output:
46e5c2c0 0000003c 11 3
CompilerBug
If you run it and get any other output, then congratulations, you’ve probably hit another bug.
The difference between the two is whether aborttrapinstr.c is inlined into aborttraparm.c or whether it’s compiled to a separate object file.
A bit more context: The code is disassembling & emulating instruction e8d3910b (“LDMIA R3,{R0,R1,R3,R8,R12,PC}^”), which will take it through the aborttrap_LDM_exception() function in aborttrapinstr.c. The value that’s being calculated incorrectly is the length of data to transfer from memory (20 bytes), so I’d imagine that it’s going wrong somewhere around the bitcount() function, but I’m struggling to reduce the code any further without making the bug go away.
The bug should be reproducible with a standard DDE install, but I’ve also seen it when using Disc & BCM2835 source trees/build targets, and when building module code.
Changelog:
Modified by Sprow (202) Sat, June 26 2021 - 11:51:39 GMT
Idle fingers tried each of these settings
https://www.chiark.greenend.org.uk/~theom/risco…
and -zpq64 or -zpq8192 or -zpq1048576 all sidestep the bug, of which -zpq1048576 is the most targetted.
Also -zpz0 but that turns off all CSE which is a rather blunt instrument.