From Bugzilla Helper: User-Agent: Mozilla/4.75 [en] (X11; U; Linux 2.2.16-22 i686) A simple purely integer computation yields the wrong answer. Reproducible: Always Steps to Reproduce: 1. Compile the following sample program (no special options, no optimization, just gcc program.c) main() { int vec[6],sum; vec[0]=24; vec[1]=18; vec[2]=12; vec[3]=6; vec[4]=0; vec[5]=-24; printf("%d %d %d %d %d %d\n",vec[0],vec[1],vec[2],vec[3],vec[4],vec[5]); sum=( -3 * vec[0] -3 * vec[1] -3 * vec[2] -3 * vec[3] -3 * vec[4]+ 3 * vec[5])/12; printf("%d\n",sum); } 2. run it Actual Results: The result of the computation, printed on the last line, is -20 Expected Results: The correct answer is -21. This is the output I obtained [t58@lion t58]$ gcc CBUG2.c [t58@lion t58]$ a.out 24 18 12 6 0 -24 -20 Using kgcc yields this correct result [t58@lion t58]$ kgcc CBUG2.c [t58@lion t58]$ a.out 24 18 12 6 0 -24 -21
Oops, looks like a bug in extract_muldiv (present on gcc-3.0-branch as well). Looking into...
I've fixed this in http://gcc.gnu.org/ml/gcc-patches/2001-02/msg01419.html, the patch will appear in gcc-2.96-77.