public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/15205] New: NEAREST intrinsic returns wrong value in DOUBLE PRECISION
@ 2004-04-29 18:01 gcc-bugzilla at gcc dot gnu dot org
2004-04-29 18:13 ` [Bug fortran/15205] [gfortran] " pinskia at gcc dot gnu dot org
` (10 more replies)
0 siblings, 11 replies; 12+ messages in thread
From: gcc-bugzilla at gcc dot gnu dot org @ 2004-04-29 18:01 UTC (permalink / raw)
To: gcc-bugs
The NEAREST intrinsic for DOUBLE PRECISION kind type is returning the
wrong value. Consider the following program:
program test_nearest
implicit none
real(4) sr, sx, ss
real(8) dr, dx, ds
sx = 1.237e0_sp
ss = 1.e0_sp
sr = nearest(sx,ss)
write(*,1) 'nearest(', sx, ',', ss, ') = ', sr
1 format(a,e15.8,a,e15.8,a,e15.8)
ss = -1.e0_sp
sr = nearest(sx,ss)
write(*,1) 'nearest(', sx, ',', ss, ') = ', sr
dx = 1.237e0_dp
ds = 1.e0_dp
dr = nearest(dx,ds)
write(*,2) 'nearest(', dx, ',', ds, ') = ', dr
2 format(a,e23.16,a,e23.16,a,e23.16)
ds = -1.e0_dp
dr = nearest(dx,ds)
write(*,2) 'nearest(', dx, ',', ds, ') = ', dr
end program test_nearest
Gfortran yields
kargl[328] ./nearest
nearest( 0.12369999E+01, 1.00000000E+00) = 0.12370001E+01
nearest( 0.12369999E+01,-1.00000000E+00) = 0.12369998E+01
nearest( 0.1237000000000000E+01, 1.0000000000000000E+00) = -0.4303249471964870E-36
nearest( 0.1237000000000000E+01,-1.0000000000000000E+00) = -0.4303249471964870E-36
NAG's compiler gives
nearest( 0.12370000E+01, 0.10000000E+01) = 0.12370001E+01
nearest( 0.12370000E+01,-0.10000000E+01) = 0.12369999E+01
nearest( 0.1237000000000000E+01, 0.1000000000000000E+01) = 0.1237000000000000E+01
nearest( 0.1237000000000000E+01,-0.1000000000000000E+01) = 0.1237000000000000E+01
Environment:
System: FreeBSD c-67-168-59-70.client.comcast.net 5.2-CURRENT FreeBSD 5.2-CURRENT #2: Sat Apr 24 10:33:08 PDT 2004 kargl@c-67-168-59-70.client.comcast.net:/usr/obj/usr/src/sys/HOTRATS i386
host: i386-unknown-freebsd5.2
build: i386-unknown-freebsd5.2
target: i386-unknown-freebsd5.2
configured with: ../gcc/configure --prefix=/home/kargl/gcc/work --disable-libmudflap --enable-languages=c,f95 --with-gmp=/usr/local
How-To-Repeat:
See above.
--
Summary: NEAREST intrinsic returns wrong value in DOUBLE
PRECISION
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: kargl at c-67-168-59-70 dot client dot comcast dot net
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: i386-unknown-freebsd5.2
GCC host triplet: i386-unknown-freebsd5.2
GCC target triplet: i386-unknown-freebsd5.2
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15205
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug fortran/15205] [gfortran] NEAREST intrinsic returns wrong value in DOUBLE PRECISION
2004-04-29 18:01 [Bug fortran/15205] New: NEAREST intrinsic returns wrong value in DOUBLE PRECISION gcc-bugzilla at gcc dot gnu dot org
@ 2004-04-29 18:13 ` pinskia at gcc dot gnu dot org
2004-04-29 18:57 ` [Bug libfortran/15205] " pinskia at gcc dot gnu dot org
` (9 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-04-29 18:13 UTC (permalink / raw)
To: gcc-bugs
--
What |Removed |Added
----------------------------------------------------------------------------
Summary|NEAREST intrinsic returns |[gfortran] NEAREST intrinsic
|wrong value in DOUBLE |returns wrong value in
|PRECISION |DOUBLE PRECISION
Target Milestone|--- |tree-ssa
Version|unknown |tree-ssa
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15205
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug libfortran/15205] [gfortran] NEAREST intrinsic returns wrong value in DOUBLE PRECISION
2004-04-29 18:01 [Bug fortran/15205] New: NEAREST intrinsic returns wrong value in DOUBLE PRECISION gcc-bugzilla at gcc dot gnu dot org
2004-04-29 18:13 ` [Bug fortran/15205] [gfortran] " pinskia at gcc dot gnu dot org
@ 2004-04-29 18:57 ` pinskia at gcc dot gnu dot org
2004-04-30 0:51 ` bdavis9659 at comcast dot net
` (8 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-04-29 18:57 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2004-04-29 18:25 -------
I can confirm this on i686-pc-linux-gnu but works on power-apple-darwin for some reason.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Component|fortran |libfortran
Ever Confirmed| |1
Last reconfirmed|0000-00-00 00:00:00 |2004-04-29 18:25:25
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15205
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug libfortran/15205] [gfortran] NEAREST intrinsic returns wrong value in DOUBLE PRECISION
2004-04-29 18:01 [Bug fortran/15205] New: NEAREST intrinsic returns wrong value in DOUBLE PRECISION gcc-bugzilla at gcc dot gnu dot org
2004-04-29 18:13 ` [Bug fortran/15205] [gfortran] " pinskia at gcc dot gnu dot org
2004-04-29 18:57 ` [Bug libfortran/15205] " pinskia at gcc dot gnu dot org
@ 2004-04-30 0:51 ` bdavis9659 at comcast dot net
2004-04-30 16:44 ` [Bug fortran/15205] " Tobias dot Schlueter at physik dot uni-muenchen dot de
` (7 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: bdavis9659 at comcast dot net @ 2004-04-30 0:51 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From bdavis9659 at comcast dot net 2004-04-30 00:36 -------
for some reason i had to remove the _sp and _dp to get it to compile ?
this is not a library problem, it is in the front end.
[bdavis@localhost pr15205]$ gfortran -static a.f90
[bdavis@localhost pr15205]$ nm a.out |grep near
527:08049140 T _gfortran_nearest_r4
or look at the output of -fdump-tree-all
[bdavis@localhost pr15205]$ grep near a.f90.t03.original
12: sr = _gfortran_nearest_r4 (sx, ss);
19: _gfortran_transfer_character ("nearest(", 8);
27: sr = _gfortran_nearest_r4 (sx, ss);
34: _gfortran_transfer_character ("nearest(", 8);
43: dr = (real8)_gfortran_nearest_r4 (dx, ds);
50: _gfortran_transfer_character ("nearest(", 8);
58: dr = (real8)_gfortran_nearest_r4 (dx, ds);
65: _gfortran_transfer_character ("nearest(", 8);
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15205
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug fortran/15205] [gfortran] NEAREST intrinsic returns wrong value in DOUBLE PRECISION
2004-04-29 18:01 [Bug fortran/15205] New: NEAREST intrinsic returns wrong value in DOUBLE PRECISION gcc-bugzilla at gcc dot gnu dot org
` (2 preceding siblings ...)
2004-04-30 0:51 ` bdavis9659 at comcast dot net
@ 2004-04-30 16:44 ` Tobias dot Schlueter at physik dot uni-muenchen dot de
2004-04-30 17:06 ` Tobias dot Schlueter at physik dot uni-muenchen dot de
` (6 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Tobias dot Schlueter at physik dot uni-muenchen dot de @ 2004-04-30 16:44 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From Tobias dot Schlueter at physik dot uni-muenchen dot de 2004-04-30 16:35 -------
(In reply to comment #2)
> for some reason i had to remove the _sp and _dp to get it to compile ?
>
> this is not a library problem, it is in the front end.
>
> [bdavis@localhost pr15205]$ gfortran -static a.f90
> [bdavis@localhost pr15205]$ nm a.out |grep near
> 527:08049140 T _gfortran_nearest_r4
>
> or look at the output of -fdump-tree-all
-fdump-parse-tree can be very helpful as well (after removing _sp and replacing
_dp by _8):
[tobi@marktplatz tests]$ gfortran pr15205.f90 -fdump-parse-tree
Namespace: A-Z: (UNKNOWN 0)
symtree: dr Ambig 0
symbol dr (REAL 8)(VARIABLE UNKNOWN-INTENT UNKNOWN-ACCESS UNKNOWN-PROC)
symtree: sx Ambig 0
symbol sx (REAL 4)(VARIABLE UNKNOWN-INTENT UNKNOWN-ACCESS UNKNOWN-PROC)
symtree: ds Ambig 0
symbol ds (REAL 8)(VARIABLE UNKNOWN-INTENT UNKNOWN-ACCESS UNKNOWN-PROC)
symtree: sr Ambig 0
symbol sr (REAL 4)(VARIABLE UNKNOWN-INTENT UNKNOWN-ACCESS UNKNOWN-PROC)
symtree: dx Ambig 0
symbol dx (REAL 8)(VARIABLE UNKNOWN-INTENT UNKNOWN-ACCESS UNKNOWN-PROC)
symtree: nearest Ambig 0
symbol nearest (UNKNOWN 0)(PROCEDURE UNKNOWN-INTENT UNKNOWN-ACCESS
UNKNOWN-PROC FUNCTION)
result: nearest
symtree: ss Ambig 0
symbol ss (REAL 4)(VARIABLE UNKNOWN-INTENT UNKNOWN-ACCESS UNKNOWN-PROC)
symtree: test_nearest Ambig 0
symbol test_nearest (UNKNOWN 0)(PROGRAM UNKNOWN-INTENT UNKNOWN-ACCESS
UNKNOWN-PROC)
ASSIGN sx 0.1237e1
ASSIGN ss 0.1e1
ASSIGN sr _gfortran_nearest[[((sx) (ss))]]
WRITE UNIT=6 FMT=1
TRANSFER 'nearest('
TRANSFER sx
TRANSFER ','
TRANSFER ss
TRANSFER ') = '
TRANSFER sr
DT_END
ASSIGN ss -0.1e1
ASSIGN sr _gfortran_nearest[[((sx) (ss))]]
WRITE UNIT=6 FMT=1
TRANSFER 'nearest('
TRANSFER sx
TRANSFER ','
TRANSFER ss
TRANSFER ') = '
TRANSFER sr
DT_END
ASSIGN dx 0.1237e1_8
ASSIGN ds 0.1e1_8
ASSIGN dr __convert_r4_r8[[((_gfortran_nearest[[((dx) (ds))]]))]]
WRITE UNIT=6 FMT=2
TRANSFER 'nearest('
TRANSFER dx
TRANSFER ','
TRANSFER ds
TRANSFER ') = '
TRANSFER dr
DT_END
ASSIGN ds -0.1e1_8
ASSIGN dr __convert_r4_r8[[((_gfortran_nearest[[((dx) (ds))]]))]]
WRITE UNIT=6 FMT=2
TRANSFER 'nearest('
TRANSFER dx
TRANSFER ','
TRANSFER ds
TRANSFER ') = '
TRANSFER dr
DT_END
[tobi@marktplatz tests]$
So yeah, the frontend is at fault.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15205
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug fortran/15205] [gfortran] NEAREST intrinsic returns wrong value in DOUBLE PRECISION
2004-04-29 18:01 [Bug fortran/15205] New: NEAREST intrinsic returns wrong value in DOUBLE PRECISION gcc-bugzilla at gcc dot gnu dot org
` (3 preceding siblings ...)
2004-04-30 16:44 ` [Bug fortran/15205] " Tobias dot Schlueter at physik dot uni-muenchen dot de
@ 2004-04-30 17:06 ` Tobias dot Schlueter at physik dot uni-muenchen dot de
2004-04-30 18:13 ` Tobias dot Schlueter at physik dot uni-muenchen dot de
` (5 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Tobias dot Schlueter at physik dot uni-muenchen dot de @ 2004-04-30 17:06 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From Tobias dot Schlueter at physik dot uni-muenchen dot de 2004-04-30 16:44 -------
I have a fix for this, as usual it's waiting for my copyright assignment. It
consists in adding a resolution function for the NEAREST intrinsic, so that the
type of the argument is properly propagated.
--
What |Removed |Added
----------------------------------------------------------------------------
CC| |Tobias dot Schlueter at
| |physik dot uni-muenchen dot
| |de
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15205
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug fortran/15205] [gfortran] NEAREST intrinsic returns wrong value in DOUBLE PRECISION
2004-04-29 18:01 [Bug fortran/15205] New: NEAREST intrinsic returns wrong value in DOUBLE PRECISION gcc-bugzilla at gcc dot gnu dot org
` (4 preceding siblings ...)
2004-04-30 17:06 ` Tobias dot Schlueter at physik dot uni-muenchen dot de
@ 2004-04-30 18:13 ` Tobias dot Schlueter at physik dot uni-muenchen dot de
2004-05-01 3:01 ` bdavis at gcc dot gnu dot org
` (4 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Tobias dot Schlueter at physik dot uni-muenchen dot de @ 2004-04-30 18:13 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From Tobias dot Schlueter at physik dot uni-muenchen dot de 2004-04-30 17:07 -------
I forgot to include this: with my patch Steve's program gives the correct answer
(except for the rounding, I don't know if that's another bug):
[tobi@marktplatz tests]$ LD_LIBRARY_PATH=~tobi/usr/lib ./a.out
nearest( 0.12369999E+01, 1.00000000E+00) = 0.12370001E+01
nearest( 0.12369999E+01,-1.00000000E+00) = 0.12369998E+01
nearest( 0.1237000000000000E+01, 1.0000000000000000E+00) = 0.1237000000000000E+01
nearest( 0.1237000000000000E+01,-1.0000000000000000E+00) = 0.1236999999999999E+01
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15205
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug fortran/15205] [gfortran] NEAREST intrinsic returns wrong value in DOUBLE PRECISION
2004-04-29 18:01 [Bug fortran/15205] New: NEAREST intrinsic returns wrong value in DOUBLE PRECISION gcc-bugzilla at gcc dot gnu dot org
` (5 preceding siblings ...)
2004-04-30 18:13 ` Tobias dot Schlueter at physik dot uni-muenchen dot de
@ 2004-05-01 3:01 ` bdavis at gcc dot gnu dot org
2004-05-08 16:17 ` Tobias dot Schlueter at physik dot uni-muenchen dot de
` (3 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: bdavis at gcc dot gnu dot org @ 2004-05-01 3:01 UTC (permalink / raw)
To: gcc-bugs
--
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot gnu |Tobias dot Schlueter at
|dot org |physik dot uni-muenchen dot
| |de
Status|NEW |ASSIGNED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15205
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug fortran/15205] [gfortran] NEAREST intrinsic returns wrong value in DOUBLE PRECISION
2004-04-29 18:01 [Bug fortran/15205] New: NEAREST intrinsic returns wrong value in DOUBLE PRECISION gcc-bugzilla at gcc dot gnu dot org
` (6 preceding siblings ...)
2004-05-01 3:01 ` bdavis at gcc dot gnu dot org
@ 2004-05-08 16:17 ` Tobias dot Schlueter at physik dot uni-muenchen dot de
2004-05-08 17:28 ` pinskia at gcc dot gnu dot org
` (2 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Tobias dot Schlueter at physik dot uni-muenchen dot de @ 2004-05-08 16:17 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From Tobias dot Schlueter at physik dot uni-muenchen dot de 2004-05-08 16:17 -------
Patch here: http://gcc.gnu.org/ml/fortran/2004-05/msg00063.html
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15205
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug fortran/15205] [gfortran] NEAREST intrinsic returns wrong value in DOUBLE PRECISION
2004-04-29 18:01 [Bug fortran/15205] New: NEAREST intrinsic returns wrong value in DOUBLE PRECISION gcc-bugzilla at gcc dot gnu dot org
` (7 preceding siblings ...)
2004-05-08 16:17 ` Tobias dot Schlueter at physik dot uni-muenchen dot de
@ 2004-05-08 17:28 ` pinskia at gcc dot gnu dot org
2004-05-14 18:38 ` cvs-commit at gcc dot gnu dot org
2004-05-14 18:52 ` tobi at gcc dot gnu dot org
10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-05-08 17:28 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2004-05-08 17:28 -------
Now I understand why it works on PPC because on PPC single pression fp are passed by register which
are always in double pression.
--
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |patch, wrong-code
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15205
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug fortran/15205] [gfortran] NEAREST intrinsic returns wrong value in DOUBLE PRECISION
2004-04-29 18:01 [Bug fortran/15205] New: NEAREST intrinsic returns wrong value in DOUBLE PRECISION gcc-bugzilla at gcc dot gnu dot org
` (8 preceding siblings ...)
2004-05-08 17:28 ` pinskia at gcc dot gnu dot org
@ 2004-05-14 18:38 ` cvs-commit at gcc dot gnu dot org
2004-05-14 18:52 ` tobi at gcc dot gnu dot org
10 siblings, 0 replies; 12+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2004-05-14 18:38 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From cvs-commit at gcc dot gnu dot org 2004-05-14 13:51 -------
Subject: Bug 15205
CVSROOT: /cvs/gcc
Module name: gcc
Changes by: tobi@gcc.gnu.org 2004-05-14 13:51:27
Modified files:
gcc/fortran : ChangeLog intrinsic.c intrinsic.h iresolve.c
Log message:
PR fortran/15205
* iresolve.c (gfc_resolve_nearest): Add new function.
* intrinsic.h: ... declare it here.
* intrinsic.c (add_functions): ... add it as resolving function
for NEAREST.
Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/fortran/ChangeLog.diff?cvsroot=gcc&r1=1.9&r2=1.10
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/fortran/intrinsic.c.diff?cvsroot=gcc&r1=1.3&r2=1.4
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/fortran/intrinsic.h.diff?cvsroot=gcc&r1=1.3&r2=1.4
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/fortran/iresolve.c.diff?cvsroot=gcc&r1=1.3&r2=1.4
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15205
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug fortran/15205] [gfortran] NEAREST intrinsic returns wrong value in DOUBLE PRECISION
2004-04-29 18:01 [Bug fortran/15205] New: NEAREST intrinsic returns wrong value in DOUBLE PRECISION gcc-bugzilla at gcc dot gnu dot org
` (9 preceding siblings ...)
2004-05-14 18:38 ` cvs-commit at gcc dot gnu dot org
@ 2004-05-14 18:52 ` tobi at gcc dot gnu dot org
10 siblings, 0 replies; 12+ messages in thread
From: tobi at gcc dot gnu dot org @ 2004-05-14 18:52 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From tobi at gcc dot gnu dot org 2004-05-14 14:00 -------
Fixed by the above commit.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15205
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2004-05-14 14:00 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-04-29 18:01 [Bug fortran/15205] New: NEAREST intrinsic returns wrong value in DOUBLE PRECISION gcc-bugzilla at gcc dot gnu dot org
2004-04-29 18:13 ` [Bug fortran/15205] [gfortran] " pinskia at gcc dot gnu dot org
2004-04-29 18:57 ` [Bug libfortran/15205] " pinskia at gcc dot gnu dot org
2004-04-30 0:51 ` bdavis9659 at comcast dot net
2004-04-30 16:44 ` [Bug fortran/15205] " Tobias dot Schlueter at physik dot uni-muenchen dot de
2004-04-30 17:06 ` Tobias dot Schlueter at physik dot uni-muenchen dot de
2004-04-30 18:13 ` Tobias dot Schlueter at physik dot uni-muenchen dot de
2004-05-01 3:01 ` bdavis at gcc dot gnu dot org
2004-05-08 16:17 ` Tobias dot Schlueter at physik dot uni-muenchen dot de
2004-05-08 17:28 ` pinskia at gcc dot gnu dot org
2004-05-14 18:38 ` cvs-commit at gcc dot gnu dot org
2004-05-14 18:52 ` tobi at gcc dot gnu dot 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).