g77 bug: int(log10(x))

Patrick Lamb lamb@huntsville.sparta.com
Thu Oct 18 14:32:00 GMT 2001


Apologies if this has been covered already.  One of my users presented
me with a test case of:

      program test
      implicit real*8 (a-h,o-z)
      a=10.
      b=log10(a)
      i=int(b)
      j=int(log10(a))
      write(6,*)a,b,i,j
      stop
      end

When compiled with no optimization and run, the output is
  10.  1. 1 0
with -O2 optimization, the result is
  10.  1. 0 0

The platform is GNU Fortran 0.5.25 19991024 (part of a gcc 2.95.2
install) on an intel Linux box.  The problem can be worked around by
using aint instead of int, but this still looks like a bug to me.

Pat

-- 
It is poor civic hygiene to install technologies that could someday 
facilitate a police state. -- Bruce Schneier

Patrick Lamb, Ph.D.           lamb@huntsville.sparta.com
(256) 837-5282 x1253 voice,   (256) 830-0287 FAX

-----BEGIN GEEK CODE BLOCK-----
Version: 3.12
GS/MU/FA/PA/CS/E d+() s+:++ a+ C++() UL++++$ P++>+++ L+++(++) E(+) 
W++@(+) N++ K? w(---) O M- PS+(++) PE Y+ PGP>+ t 5? X? R tv(+) b++(+++)
DI++(++++) D+ G e++++ h--- r+++ y++++
------END GEEK CODE BLOCK------



More information about the Gcc-bugs mailing list