[patch, fortran] Warn about integer**(negative integer)
Thomas Koenig
tkoenig@netcologne.de
Mon Jan 23 19:45:00 GMT 2017
Hi FX,
> The idea seems reasonable, but I am not sure about the wording
> (âtruncatedâ in particular). âInteger exponentiation truncated
> to constant 0â? Why not âNegative integer exponent has result
> value zeroâ?
>
> Other than that, OK to commit.
You're right, the error message was a bit strange. Here is the
version of the patch I committed with corresponding change in the
test case.
Regards
Thomas
Index: fortran/arith.c
===================================================================
--- fortran/arith.c (Revision 244747)
+++ fortran/arith.c (Arbeitskopie)
@@ -874,6 +874,10 @@ arith_power (gfc_expr *op1, gfc_expr *op2, gfc_exp
{
/* if op2 < 0, op1**op2 == 0 because abs(op1) > 1. */
mpz_set_si (result->value.integer, 0);
+ if (warn_integer_division)
+ gfc_warning_now (OPT_Winteger_division, "Negative
"
+ "exponent of integer has zero "
+ "result at %L", &result->where);
}
else if (gfc_extract_int (op2, &power))
{
More information about the Fortran
mailing list