https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78676

            Bug ID: 78676
           Summary: Optimizer bug exposed by program with many bit
                    operations.
           Product: gcc
           Version: 6.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: mecej4 at operamail dot com
  Target Milestone: ---

Created attachment 40244
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=40244&action=edit
Test program to demonstrate bug; run with (i) -O and (ii) -O2, and compare the
output

The attached test program runs and gives correct results when compiled with
Gfortran 6.2 without any optimization or with -O. It gives incorrect results
when compiled with -O2. Since the program works entirely with integer
variables, exact results are to be expected.

The bug was encountered when running George Marsaglia's KISS random number
generator, see http://mathforum.org/kb/message.jspa?messageID=6914945 . His
benchmark program runs a billion iterations, whereas the attached program does
only ten iterations. The errors appear to be small but, by increasing the
parameter QSIZ to a few millions, it can be seen that the errors grow
catastrophically. 

Again, since no real number arithmetic is involved, there is no expectation of
obtaining different results on different platforms. The results given by
Gfortran with -O or without any optimization are in agreement with results from
other compilers (NAG, Intel).

Reply via email to