https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114872
Dmitrii Pasechnik <dima.pasechnik at cs dot ox.ac.uk> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |dima.pasechnik at cs dot
ox.ac.uk
--- Comment #12 from Dmitrii Pasechnik <dima.pasechnik at cs dot ox.ac.uk> ---
A colleague disassembled, using ghidra (https://ghidra-sre.org/), the results
of the compilations with, respectively, -O2 and with -O0 flags.
Comparing the results, in the broken (built with -O2) case one sees a
miscompilation of a call to GAP_CallFunc3Args - it is called with one argument
less than it should, three instead of four!
broken (-O2):
> plVar9 = (long *)GAP_CallFunc3Args(*(undefined8 *)(param_1 +
> 0x20),local_a0[4],
> local_a8[4]);
vs. good (-O0):
< LAB_0013cbd9:
< plVar10 = (long *)GAP_CallFunc3Args(*(undefined8 *)(param_1 +
0x20),local_a8[4],
< local_a0[4],plVar16[4]);
And this is despite the prototype for calling GAP_CallFunc3Args() is
found in "gap/libgap-api.h", which is included in example.c as #include
"gap/libgap-api.h", meant to be respected during the compilation.
I hope this helps in chasing down the obvious compiler bug. Perhaps it can be
also seen without disassembling, simply on the intermediate data generated by
the compiler.