[forwarded from http://bugs.debian.org/285238] works with 3.4.3 gcc-3.3 -O3 -fPIC miscompile pari on ARM. (see <http://buildd.debian.org/fetch.php?&pkg=pari&ver=2.1.6-1&arch=arm&stamp=1102707589&file=log&as=raw>) More precisely the file src/basemath/alglin1.c is miscompiled with -O3 -fPIC but correctly compiled with -O3 or -O2 -fPIC This is a regression since gcc-3.3_1:3.3.2-0pre5 built the same file correctly with -O3 -fPIC. Apparenlty gcc inline the function use_maximal_pivot() inside gauss_pivot_ker() and produce wrong code there. Removing the static qualifier from use_maximal_pivot() (thus forbidding the compiler to enable) work around the bug.
Created attachment 7747 [details] preprocessed source
use_maximal_pivot() is casting longs to pointers and vice-versa. I strongly suspect this code is violating C's aliasing rules. The inlining of the function then opens up more chances for the scheduler to move things out of order. Does the program run correctly if you use -fno-strict-alias?
the bug submitter replied: I suppose you mean -fno-strict-aliasing, since -fno-strict-alias does not exist. In this case that does not fix the problem. This code work correctly when build with the same compiler on 10 other platforms and AFAIK, casting long* to long does not break strict aliasing rules.
Compiling the testcase with '-O3 -fPIC' using stock gcc-3.3.2 and gcc-3.3.5 configured for arm-linux produces identical assembly code for gauss_pivot_ker(). So I don't see what the bug can be.