------- Comment #2 from burnus at gcc dot gnu dot org 2007-01-20 12:46 ------- Non-library part of this fix. This fixes the reported bug, but libgfortran/m4/* should be fixed as well.
m4/iparm.m4 contains: define(atype_max, atype_name`_HUGE')dnl define(atype_min, `-'atype_max)dnl One would need to put an "ifelse" for atype_min, but I'm rather illiterate in m4. Index: trans-intrinsic.c =================================================================== --- trans-intrinsic.c (Revision 120999) +++ trans-intrinsic.c (Arbeitskopie) @@ -1976,11 +1976,16 @@ gcc_unreachable (); } - /* Most negative(+HUGE) for maxval, most negative (-HUGE) for minval. */ + /* Most negative(-HUGE) for maxloc, most positiv (+HUGE) for minloc. */ if (op == GT_EXPR) tmp = fold_build1 (NEGATE_EXPR, TREE_TYPE (tmp), tmp); gfc_add_modify_expr (&se->pre, limit, tmp); + /* Most negative for BT_INTEGER is -HUGE-1. */ + if (op == GT_EXPR && expr->ts.type == BT_INTEGER) + tmp = build2 (MINUS_EXPR, TREE_TYPE (tmp), tmp, + build_int_cst (type, 1)); + /* Initialize the scalarizer. */ gfc_init_loopinfo (&loop); gfc_add_ss_to_loop (&loop, arrayss); @@ -2135,9 +2140,15 @@ gcc_unreachable (); } - /* Most negative(-HUGE) for maxval, most positive (-HUGE) for minval. */ + /* Most negative(-HUGE) for maxval, most positive (+HUGE) for minval. */ if (op == GT_EXPR) tmp = fold_build1 (NEGATE_EXPR, TREE_TYPE (tmp), tmp); + + /* Most negative for BT_INTEGER is -HUGE-1. */ + if (op == GT_EXPR && expr->ts.type == BT_INTEGER) + tmp = build2 (MINUS_EXPR, TREE_TYPE (tmp), tmp, + build_int_cst (type, 1)); + gfc_add_modify_expr (&se->pre, limit, tmp); /* Walk the arguments. */ -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30512