[Bug fortran/30752] New: SECNDS() or DATE_AND_TIME() intrinsic optimized incorrectly.
brooks at gcc dot gnu dot org
gcc-bugzilla@gcc.gnu.org
Sat Feb 10 00:12:00 GMT 2007
Consider the following piece of code, derived from the secnds-1.f test case
(with some changes I'd added to avoid the 20ms arbitrary tolerance):
C {dg-do run}
character*20 dum1, dum2, dum3
real t1, t1a, t2, t2a
real dat1, dat2
integer i, j, values(8)
t1 = secnds (0.0)
call date_and_time (dum1, dum2, dum3, values)
t1a = secnds (0.0)
dat1 = 0.001*real (values(8)) + real (values(7)) +
& 60.0*real (values(6)) + 3600.0* real (values(5))
C The following line is critical here.
C write (*,*) (((dat1 - t1) < 0.) .or. ((dat1 - t1) > (t1a - t1)))
if (((dat1 - t1) < 0.) .or. ((dat1 - t1) > (t1a - t1))) then
write (*,*) (((dat1 - t1) < 0.) .or. ((dat1 - t1) > (t1a - t1)))
write (*,*) dat1, t1, t1a, dat1-t1, t1a-t1
call abort ()
end if
end
If I run this through the usual testsuite apparatus, it will fail on about 30%
(on average) of the optimized runs, but never (so far as I've seen) with -O0.
The output, though, usually looks like this:
F
16806.37 16806.37 16806.37 0.000000 0.000000
Note the "F", for the exact check that just evaluated as true in the IF
statement.
If I uncomment the WRITE statement prior to the IF, the failures go away.
--
Summary: SECNDS() or DATE_AND_TIME() intrinsic optimized
incorrectly.
Product: gcc
Version: 4.3.0
Status: UNCONFIRMED
Keywords: wrong-code
Severity: normal
Priority: P3
Component: fortran
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: brooks at gcc dot gnu dot org
GCC build triplet: i686-pc-linux-gnu
GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30752
More information about the Gcc-bugs
mailing list