https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107680

--- Comment #2 from anlauf at gcc dot gnu.org ---
We could prohibit the simplification of ** like in the following:

diff --git a/gcc/fortran/arith.cc b/gcc/fortran/arith.cc
index fc9224ebc5c..540b8e2b945 100644
--- a/gcc/fortran/arith.cc
+++ b/gcc/fortran/arith.cc
@@ -845,6 +845,12 @@ arith_power (gfc_expr *op1, gfc_expr *op2, gfc_expr
**resultp)
   if (!gfc_numeric_ts (&op1->ts) || !gfc_numeric_ts (&op2->ts))
     return ARITH_INVALID_TYPE;

+  /* The result type shall accomodate the result of the simplification.  */
+  if (op1->ts.type == BT_INTEGER && op2->ts.type != BT_INTEGER)
+    return ARITH_NOT_REDUCED;
+  if (op1->ts.type == BT_REAL && op2->ts.type == BT_COMPLEX)
+    return ARITH_NOT_REDUCED;
+
   rc = ARITH_OK;
   result = gfc_get_constant_expr (op1->ts.type, op1->ts.kind, &op1->where);

Reply via email to