diff mbox

[fortran] Warn about integer**(negative integer)

Message ID d1de468c-6185-77b9-8abe-a3fa74ca5ab5@netcologne.de
State New
Headers show

Commit Message

Thomas Koenig Jan. 23, 2017, 7:45 p.m. UTC
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


                 else if (gfc_extract_int (op2, &power))
                   {
diff mbox

Patch

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);
                   }