[Bug fortran/107680] ICE in arith_power, at fortran/arith.cc:989 and :1006

2022-11-28 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107680

Andrew Pinski  changed:

   What|Removed |Added

   Target Milestone|--- |13.0

[Bug fortran/107680] ICE in arith_power, at fortran/arith.cc:989 and :1006

2022-11-18 Thread anlauf at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107680

anlauf at gcc dot gnu.org changed:

   What|Removed |Added

 Resolution|--- |FIXED
 Status|ASSIGNED|RESOLVED

--- Comment #7 from anlauf at gcc dot gnu.org ---
Fixed on mainline.

The open issue of the fate(?) of the typespec is tracked in pr107721.

Thanks for the report!

[Bug fortran/107680] ICE in arith_power, at fortran/arith.cc:989 and :1006

2022-11-16 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107680

--- Comment #6 from CVS Commits  ---
The master branch has been updated by Harald Anlauf :

https://gcc.gnu.org/g:713dcfc85ebbabaf74a1bcbac4ba1143519b31d6

commit r13-4106-g713dcfc85ebbabaf74a1bcbac4ba1143519b31d6
Author: Harald Anlauf 
Date:   Tue Nov 15 21:20:20 2022 +0100

Fortran: ICE in simplification of array expression involving power
[PR107680]

gcc/fortran/ChangeLog:

PR fortran/107680
* arith.cc (arith_power): Check that operands are properly
converted
before attempting to simplify.

gcc/testsuite/ChangeLog:

PR fortran/107680
* gfortran.dg/pr107680.f90: New test.

[Bug fortran/107680] ICE in arith_power, at fortran/arith.cc:989 and :1006

2022-11-15 Thread anlauf at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107680

anlauf at gcc dot gnu.org changed:

   What|Removed |Added

   Assignee|unassigned at gcc dot gnu.org  |anlauf at gcc dot 
gnu.org
 Status|NEW |ASSIGNED

--- Comment #5 from anlauf at gcc dot gnu.org ---
Taking: https://gcc.gnu.org/pipermail/fortran/2022-November/058509.html

[Bug fortran/107680] ICE in arith_power, at fortran/arith.cc:989 and :1006

2022-11-15 Thread anlauf at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107680

--- Comment #4 from anlauf at gcc dot gnu.org ---
(In reply to Mikael Morin from comment #3)
> I thought the call to gfc_type_convert_binary in eval_intrinsic was taking
> care of mismatching types, doesn't it?

It does, and then it doesn't do it sometimes...

For

  real, parameter :: x(*) = [real :: ([1])]   **  2.0

after adding breakpoints in gfc_type_convert_binary and arith_power,
I see correct types in the former (e->value.op.op2->ts.type = BT_REAL)
but incorrect types in the latter (op1->ts.type = BT_INTEGER).

It seems to be the ratatouille of parentheses, array constructors,
typespec, and arithmetic operation that is crucial to get this type
of error.

In 12-branch, I also see other bad things happening, which I believe have
partially been fixed by the series of patches for pr107000 and friends.
Try:

  print *, [integer :: ([3.0])] **  2.0

This gives

0.

for all versions <= 12, and

9.

for mainline.

Given these observations, I suspect that typespecs are not consistently
handled...  See also the previous discussions.

[Bug fortran/107680] ICE in arith_power, at fortran/arith.cc:989 and :1006

2022-11-15 Thread mikael at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107680

Mikael Morin  changed:

   What|Removed |Added

 CC||mikael at gcc dot gnu.org

--- Comment #3 from Mikael Morin  ---
I thought the call to gfc_type_convert_binary in eval_intrinsic was taking care
of mismatching types, doesn't it?

[Bug fortran/107680] ICE in arith_power, at fortran/arith.cc:989 and :1006

2022-11-14 Thread anlauf at gcc dot gnu.org via Gcc-bugs
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 (>ts) || !gfc_numeric_ts (>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, >where);

[Bug fortran/107680] ICE in arith_power, at fortran/arith.cc:989 and :1006

2022-11-14 Thread anlauf at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107680

anlauf at gcc dot gnu.org changed:

   What|Removed |Added

 CC||anlauf at gcc dot gnu.org
 Ever confirmed|0   |1
   Last reconfirmed||2022-11-14
 Status|UNCONFIRMED |NEW

--- Comment #1 from anlauf at gcc dot gnu.org ---
Confirmed.