public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/66864] New: floor function error
@ 2015-07-14 5:04 dm577216smith at gmail dot com
2015-07-14 17:04 ` [Bug fortran/66864] " kargl at gcc dot gnu.org
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: dm577216smith at gmail dot com @ 2015-07-14 5:04 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66864
Bug ID: 66864
Summary: floor function error
Product: gcc
Version: 5.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: dm577216smith at gmail dot com
Target Milestone: ---
Here is a small program showing an error in the FLOOR function on my machine.
I get similar results with gfortran 5.1 and also an older 4.6 version.
I noticed that each of the incorrect results, 94906264, 777666496, and
2000111104
seem to be the correct value chopped to 24 bits.
Also, if I compile the program with 64-bit integers with -fdefault-integer-8,
all the results are ok.
PROGRAM T
DOUBLE PRECISION :: X
WRITE (*,*) ' '
X = 2.0D0 ** 26.5D0
WRITE (*,*) ' X = 2.0D0 ** 26.5D0 = ', X
WRITE (*,*) ' FLOOR(X) = ', FLOOR(X)
WRITE (*,*) ' '
WRITE (*,*) ' But FLOOR( 2.0D0 ** 26.5D0 ) = ', FLOOR( 2.0D0 ** 26.5D0 )
WRITE (*,*) ' '
WRITE (*,*) ' '
X = 777666555.6D0
WRITE (*,*) ' X = 777666555.6D0 gives ', X,' FLOOR(X) = ', FLOOR(X)
WRITE (*,*) ' '
WRITE (*,*) ' But FLOOR(777666555.6D0) = ', FLOOR(777666555.6D0)
WRITE (*,*) ' '
WRITE (*,*) ' '
X = 2000111222.6D0
WRITE (*,*) ' X = 2000111222.6D0 gives ', X,' FLOOR(X) = ', FLOOR(X)
WRITE (*,*) ' '
WRITE (*,*) ' But FLOOR(2000111222.6D0) = ', FLOOR(2000111222.6D0)
WRITE (*,*) ' '
WRITE (*,*) ' '
END PROGRAM T
Output from the program:
X = 2.0D0 ** 26.5D0 = 94906265.624251559
FLOOR(X) = 94906265
But FLOOR( 2.0D0 ** 26.5D0 ) = 94906264
X = 777666555.6D0 gives 777666555.60000002 FLOOR(X) = 777666555
But FLOOR(777666555.6D0) = 777666496
X = 2000111222.6D0 gives 2000111222.5999999 FLOOR(X) = 2000111222
But FLOOR(2000111222.6D0) = 2000111104
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug fortran/66864] floor function error
2015-07-14 5:04 [Bug fortran/66864] New: floor function error dm577216smith at gmail dot com
@ 2015-07-14 17:04 ` kargl at gcc dot gnu.org
2015-07-14 19:02 ` sgk at troutmask dot apl.washington.edu
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: kargl at gcc dot gnu.org @ 2015-07-14 17:04 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66864
kargl at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2015-07-14
CC| |kargl at gcc dot gnu.org
Ever confirmed|0 |1
Known to fail| |4.7.4, 4.8.5, 4.9.3, 5.1.1,
| |6.0
--- Comment #1 from kargl at gcc dot gnu.org ---
It seems constant folding in simplify.c may be broken. Here's
a testcase suitable for the testsuite once the bug is fixed.
! { dg-do run }
! PR fortran/66864
!
program t
implicit none
real(8) x
x = 2.0d0**26.5d0
if (floor(x) /= 94906265) call abort
if (floor(2.0d0**26.5d0)/= 94906265) call abort
x = 777666555.6d0
if (floor(x) /= 777666555) call abort
if (floor(777666555.6d0) /= 777666555) call abort
x = 2000111222.6d0
if (floor(x) /= 2000111222) call abort
if (floor(2000111222.6d0) /= 2000111222) call abort
end program t
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug fortran/66864] floor function error
2015-07-14 5:04 [Bug fortran/66864] New: floor function error dm577216smith at gmail dot com
2015-07-14 17:04 ` [Bug fortran/66864] " kargl at gcc dot gnu.org
@ 2015-07-14 19:02 ` sgk at troutmask dot apl.washington.edu
2015-07-14 19:31 ` sgk at troutmask dot apl.washington.edu
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: sgk at troutmask dot apl.washington.edu @ 2015-07-14 19:02 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66864
--- Comment #2 from Steve Kargl <sgk at troutmask dot apl.washington.edu> ---
On Tue, Jul 14, 2015 at 05:03:55PM +0000, kargl at gcc dot gnu.org wrote:
>
> --- Comment #1 from kargl at gcc dot gnu.org ---
> It seems constant folding in simplify.c may be broken. Here's
> a testcase suitable for the testsuite once the bug is fixed.
I have a patch.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug fortran/66864] floor function error
2015-07-14 5:04 [Bug fortran/66864] New: floor function error dm577216smith at gmail dot com
2015-07-14 17:04 ` [Bug fortran/66864] " kargl at gcc dot gnu.org
2015-07-14 19:02 ` sgk at troutmask dot apl.washington.edu
@ 2015-07-14 19:31 ` sgk at troutmask dot apl.washington.edu
2015-07-14 21:57 ` sgk at troutmask dot apl.washington.edu
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: sgk at troutmask dot apl.washington.edu @ 2015-07-14 19:31 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66864
--- Comment #3 from Steve Kargl <sgk at troutmask dot apl.washington.edu> ---
On Tue, Jul 14, 2015 at 07:02:32PM +0000, sgk at troutmask dot
apl.washington.edu wrote:
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66864
>
> --- Comment #2 from Steve Kargl <sgk at troutmask dot apl.washington.edu> ---
> On Tue, Jul 14, 2015 at 05:03:55PM +0000, kargl at gcc dot gnu.org wrote:
> >
> > --- Comment #1 from kargl at gcc dot gnu.org ---
> > It seems constant folding in simplify.c may be broken. Here's
> > a testcase suitable for the testsuite once the bug is fixed.
>
> I have a patch.
>
Patch posted.
https://gcc.gnu.org/ml/gcc-patches/2015-07/msg01193.html
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug fortran/66864] floor function error
2015-07-14 5:04 [Bug fortran/66864] New: floor function error dm577216smith at gmail dot com
` (2 preceding siblings ...)
2015-07-14 19:31 ` sgk at troutmask dot apl.washington.edu
@ 2015-07-14 21:57 ` sgk at troutmask dot apl.washington.edu
2015-07-16 19:23 ` kargl at gcc dot gnu.org
2015-07-16 19:23 ` kargl at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: sgk at troutmask dot apl.washington.edu @ 2015-07-14 21:57 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66864
--- Comment #4 from Steve Kargl <sgk at troutmask dot apl.washington.edu> ---
On Tue, Jul 14, 2015 at 12:31:11PM -0700, Steve Kargl wrote:
> On Tue, Jul 14, 2015 at 07:02:32PM +0000, sgk at troutmask dot apl.washington.edu wrote:
> > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66864
> >
> > --- Comment #2 from Steve Kargl <sgk at troutmask dot apl.washington.edu> ---
> > On Tue, Jul 14, 2015 at 05:03:55PM +0000, kargl at gcc dot gnu.org wrote:
> > >
> > > --- Comment #1 from kargl at gcc dot gnu.org ---
> > > It seems constant folding in simplify.c may be broken. Here's
> > > a testcase suitable for the testsuite once the bug is fixed.
> >
> > I have a patch.
> >
>
> Patch posted.
>
> https://gcc.gnu.org/ml/gcc-patches/2015-07/msg01193.html
>
I committed the patch to trunk, but forgot to include
the PR number in the ChangeLog entry.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug fortran/66864] floor function error
2015-07-14 5:04 [Bug fortran/66864] New: floor function error dm577216smith at gmail dot com
` (4 preceding siblings ...)
2015-07-16 19:23 ` kargl at gcc dot gnu.org
@ 2015-07-16 19:23 ` kargl at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: kargl at gcc dot gnu.org @ 2015-07-16 19:23 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66864
kargl at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution|--- |FIXED
Target Milestone|--- |5.3
--- Comment #6 from kargl at gcc dot gnu.org ---
Fixed on trunk and 5-branch. Thanks for the bug report.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug fortran/66864] floor function error
2015-07-14 5:04 [Bug fortran/66864] New: floor function error dm577216smith at gmail dot com
` (3 preceding siblings ...)
2015-07-14 21:57 ` sgk at troutmask dot apl.washington.edu
@ 2015-07-16 19:23 ` kargl at gcc dot gnu.org
2015-07-16 19:23 ` kargl at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: kargl at gcc dot gnu.org @ 2015-07-16 19:23 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66864
--- Comment #5 from kargl at gcc dot gnu.org ---
Author: kargl
Date: Thu Jul 16 19:22:38 2015
New Revision: 225903
URL: https://gcc.gnu.org/viewcvs?rev=225903&root=gcc&view=rev
Log:
2015-07-16 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/66864
* simplify.c (gfc_simplify_floor): Set precision of temporary to
that of arg.
2015-07-16 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/66864
* gfortran.dg/pr66864.f90: New test.
Added:
branches/gcc-5-branch/gcc/testsuite/gfortran.dg/pr66864.f90
Modified:
branches/gcc-5-branch/gcc/fortran/ChangeLog
branches/gcc-5-branch/gcc/fortran/simplify.c
branches/gcc-5-branch/gcc/testsuite/ChangeLog
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2015-07-16 19:23 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-14 5:04 [Bug fortran/66864] New: floor function error dm577216smith at gmail dot com
2015-07-14 17:04 ` [Bug fortran/66864] " kargl at gcc dot gnu.org
2015-07-14 19:02 ` sgk at troutmask dot apl.washington.edu
2015-07-14 19:31 ` sgk at troutmask dot apl.washington.edu
2015-07-14 21:57 ` sgk at troutmask dot apl.washington.edu
2015-07-16 19:23 ` kargl at gcc dot gnu.org
2015-07-16 19:23 ` kargl at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).