This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libfortran/34209] run-time lib: NEAREST(0.0_8, -1.0) produces wrong numbers
- From: "jvdelisle at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 23 Nov 2007 21:14:16 -0000
- Subject: [Bug libfortran/34209] run-time lib: NEAREST(0.0_8, -1.0) produces wrong numbers
- References: <bug-34209-13404@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #3 from jvdelisle at gcc dot gnu dot org 2007-11-23 21:14 -------
This appears to fix the problem:
}
void
! gfc_resolve_nearest (gfc_expr *f, gfc_expr *a, gfc_expr *p)
{
+ if (p != NULL && p->ts.kind < a->ts.kind)
+ {
+ if (a->ts.kind == gfc_kind_max (a,p))
+ gfc_convert_type (p, &a->ts, 2);
+ else
+ gfc_convert_type (a, &p->ts, 2);
+ }
f->ts = a->ts;
f->value.function.name
= gfc_get_string ("__nearest_%c%d", gfc_type_letter (a->ts.type),
We might want to think this through a bit for other combinations of kinds in
the arguments given.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34209