This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/28094] Modulo of real(kind=10) variables doesn't work
- From: "fxcoudert at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 21 Jun 2006 14:49:58 -0000
- Subject: [Bug fortran/28094] Modulo of real(kind=10) variables doesn't work
- References: <bug-28094-10259@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #2 from fxcoudert at gcc dot gnu dot org 2006-06-21 14:49 -------
This "modulo" code is not very clear in my head. I'm not sure why this
implementation (using an integer kind *equal* to the real kind) is supposed to
be working. Anyway, without changing the current implentation, this bug can be
fixed by the following patch:
Index: trans-intrinsic.c
===================================================================
--- trans-intrinsic.c (revision 114791)
+++ trans-intrinsic.c (working copy)
@@ -860,7 +860,7 @@
tree test;
tree test2;
mpfr_t huge;
- int n;
+ int n, ikind;
arg = gfc_conv_intrinsic_function_args (se, expr);
arg2 = TREE_VALUE (TREE_CHAIN (arg));
@@ -886,7 +886,13 @@
/* Test if the value is too large to handle sensibly. */
gfc_set_model_kind (expr->ts.kind);
mpfr_init (huge);
- n = gfc_validate_kind (BT_INTEGER, expr->ts.kind, false);
+ n = gfc_validate_kind (BT_INTEGER, expr->ts.kind, true);
+ ikind = expr->ts.kind;
+ if (n < 0)
+ {
+ n = gfc_validate_kind (BT_INTEGER, gfc_max_integer_kind, false);
+ ikind = gfc_max_integer_kind;
+ }
mpfr_set_z (huge, gfc_integer_kinds[n].huge, GFC_RND_MODE);
test = gfc_conv_mpfr_to_tree (huge, expr->ts.kind);
test2 = build2 (LT_EXPR, boolean_type_node, tmp, test);
@@ -896,7 +902,7 @@
test = build2 (GT_EXPR, boolean_type_node, tmp, test);
test2 = build2 (TRUTH_AND_EXPR, boolean_type_node, test, test2);
- itype = gfc_get_int_type (expr->ts.kind);
+ itype = gfc_get_int_type (ikind);
if (modulo)
tmp = build_fix_expr (&se->pre, tmp, itype, FIX_FLOOR_EXPR);
else
--
fxcoudert at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot gnu |fxcoudert at gcc dot gnu dot
|dot org |org
Status|UNCONFIRMED |ASSIGNED
Ever Confirmed|0 |1
Keywords| |patch
Known to fail| |4.2.0 4.1.2
Last reconfirmed|0000-00-00 00:00:00 |2006-06-21 14:49:58
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28094