* [Bug fortran/104848] ICE in simplify_intrinsic_op, at fortran/expr.cc:1305
2022-03-08 20:00 [Bug fortran/104848] New: ICE in simplify_intrinsic_op, at fortran/expr.cc:1305 gscfq@t-online.de
@ 2022-03-09 19:34 ` anlauf at gcc dot gnu.org
2022-03-09 19:36 ` anlauf at gcc dot gnu.org
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: anlauf at gcc dot gnu.org @ 2022-03-09 19:34 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104848
anlauf at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Ever confirmed|0 |1
CC| |anlauf at gcc dot gnu.org
Status|UNCONFIRMED |NEW
Last reconfirmed| |2022-03-09
--- Comment #1 from anlauf at gcc dot gnu.org ---
Interesting. It might be the arithmetic overflow that is not properly handled.
program p
integer, parameter :: a(2, 0) = 0
integer, parameter :: y(*) = minval(a, dim=2)
print *, y ! no ICE
print *, y-1 ! no ICE
print *, y+1 ! ICE
end
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug fortran/104848] ICE in simplify_intrinsic_op, at fortran/expr.cc:1305
2022-03-08 20:00 [Bug fortran/104848] New: ICE in simplify_intrinsic_op, at fortran/expr.cc:1305 gscfq@t-online.de
2022-03-09 19:34 ` [Bug fortran/104848] " anlauf at gcc dot gnu.org
@ 2022-03-09 19:36 ` anlauf at gcc dot gnu.org
2022-03-09 19:54 ` anlauf at gcc dot gnu.org
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: anlauf at gcc dot gnu.org @ 2022-03-09 19:36 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104848
--- Comment #2 from anlauf at gcc dot gnu.org ---
Forgot to add:
print *, y+1_8 ! no ICE
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug fortran/104848] ICE in simplify_intrinsic_op, at fortran/expr.cc:1305
2022-03-08 20:00 [Bug fortran/104848] New: ICE in simplify_intrinsic_op, at fortran/expr.cc:1305 gscfq@t-online.de
2022-03-09 19:34 ` [Bug fortran/104848] " anlauf at gcc dot gnu.org
2022-03-09 19:36 ` anlauf at gcc dot gnu.org
@ 2022-03-09 19:54 ` anlauf at gcc dot gnu.org
2022-03-09 20:17 ` anlauf at gcc dot gnu.org
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: anlauf at gcc dot gnu.org @ 2022-03-09 19:54 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104848
--- Comment #3 from anlauf at gcc dot gnu.org ---
Workaround: using -fno-range-check produces an error where appropriate.
Debugging suggests a potential fix for the ICE (needs testing):
diff --git a/gcc/fortran/expr.cc b/gcc/fortran/expr.cc
index c9c0ba4cc2e..cfafe10f727 100644
--- a/gcc/fortran/expr.cc
+++ b/gcc/fortran/expr.cc
@@ -1293,7 +1293,7 @@ simplify_intrinsic_op (gfc_expr *p, int type)
gfc_internal_error ("simplify_intrinsic_op(): Bad operator");
}
- if (result == NULL)
+ if (result == NULL || result->expr_type == EXPR_UNKNOWN)
{
gfc_free_expr (op1);
gfc_free_expr (op2);
But that may be just a band-aid.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug fortran/104848] ICE in simplify_intrinsic_op, at fortran/expr.cc:1305
2022-03-08 20:00 [Bug fortran/104848] New: ICE in simplify_intrinsic_op, at fortran/expr.cc:1305 gscfq@t-online.de
` (2 preceding siblings ...)
2022-03-09 19:54 ` anlauf at gcc dot gnu.org
@ 2022-03-09 20:17 ` anlauf at gcc dot gnu.org
2022-10-19 19:18 ` anlauf at gcc dot gnu.org
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: anlauf at gcc dot gnu.org @ 2022-03-09 20:17 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104848
--- Comment #4 from anlauf at gcc dot gnu.org ---
(In reply to anlauf from comment #3)
> But that may be just a band-aid.
Not even that.
The following example shows that bad overflow handling is a regression that
was likely introduced in 6.x:
program p
integer, parameter :: b(0) = 1 + [ huge(1) ]
end
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug fortran/104848] ICE in simplify_intrinsic_op, at fortran/expr.cc:1305
2022-03-08 20:00 [Bug fortran/104848] New: ICE in simplify_intrinsic_op, at fortran/expr.cc:1305 gscfq@t-online.de
` (3 preceding siblings ...)
2022-03-09 20:17 ` anlauf at gcc dot gnu.org
@ 2022-10-19 19:18 ` anlauf at gcc dot gnu.org
2024-03-22 21:26 ` anlauf at gcc dot gnu.org
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: anlauf at gcc dot gnu.org @ 2022-10-19 19:18 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104848
--- Comment #5 from anlauf at gcc dot gnu.org ---
(In reply to anlauf from comment #4)
> The following example shows that bad overflow handling is a regression that
> was likely introduced in 6.x:
>
> program p
> integer, parameter :: b(0) = 1 + [ huge(1) ]
> end
Another potential fix for this is:
diff --git a/gcc/fortran/arith.cc b/gcc/fortran/arith.cc
index fc9224ebc5c..67ef10d4bf7 100644
--- a/gcc/fortran/arith.cc
+++ b/gcc/fortran/arith.cc
@@ -1710,8 +1720,8 @@ eval_intrinsic (gfc_intrinsic_op op,
if (rc != ARITH_OK)
{
gfc_error (gfc_arith_error (rc), &op1->where);
- if (rc == ARITH_OVERFLOW)
- goto done;
+ // if (rc == ARITH_OVERFLOW)
+ // goto done;
if (rc == ARITH_DIV0 && op2->ts.type == BT_INTEGER)
gfc_seen_div0 = true;
While this fixes the testcases in this PR, this regresses on the following:
gfortran.dg/pr84734.f90 (from r8-7226, which added the above commented code),
gfortran.dg/integer_exponentiation_6.F90 (from r5-7381)
The latter is a weird testcase, which changed behavior and prints different
values (0 for gfortran <= 8, 4611686018427387904 for gfortran >= 9).
(Other compilers print either 0 oder produce an error, so the current
behavior is sort of at odds with the others.)
Do we have a concept for how to handle integer and real overflow depending on
the flag -f(no-)range-check?
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug fortran/104848] ICE in simplify_intrinsic_op, at fortran/expr.cc:1305
2022-03-08 20:00 [Bug fortran/104848] New: ICE in simplify_intrinsic_op, at fortran/expr.cc:1305 gscfq@t-online.de
` (4 preceding siblings ...)
2022-10-19 19:18 ` anlauf at gcc dot gnu.org
@ 2024-03-22 21:26 ` anlauf at gcc dot gnu.org
2024-03-22 21:30 ` anlauf at gcc dot gnu.org
2024-04-02 17:49 ` anlauf at gcc dot gnu.org
7 siblings, 0 replies; 9+ messages in thread
From: anlauf at gcc dot gnu.org @ 2024-03-22 21:26 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104848
anlauf at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Known to work| |14.0
--- Comment #6 from anlauf at gcc dot gnu.org ---
The ICEs are gone at r14-9631, likely by the fixes r14-8902 and r14-9340.
Testcases z1 and z2 are now properly rejected.
The overflow for testcase z3 is not detected.
I think there is a related PR on this.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug fortran/104848] ICE in simplify_intrinsic_op, at fortran/expr.cc:1305
2022-03-08 20:00 [Bug fortran/104848] New: ICE in simplify_intrinsic_op, at fortran/expr.cc:1305 gscfq@t-online.de
` (5 preceding siblings ...)
2024-03-22 21:26 ` anlauf at gcc dot gnu.org
@ 2024-03-22 21:30 ` anlauf at gcc dot gnu.org
2024-04-02 17:49 ` anlauf at gcc dot gnu.org
7 siblings, 0 replies; 9+ messages in thread
From: anlauf at gcc dot gnu.org @ 2024-03-22 21:30 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104848
anlauf at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
See Also| |https://gcc.gnu.org/bugzill
| |a/show_bug.cgi?id=99852
--- Comment #7 from anlauf at gcc dot gnu.org ---
Found pr99852, which reported the missed overflows.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug fortran/104848] ICE in simplify_intrinsic_op, at fortran/expr.cc:1305
2022-03-08 20:00 [Bug fortran/104848] New: ICE in simplify_intrinsic_op, at fortran/expr.cc:1305 gscfq@t-online.de
` (6 preceding siblings ...)
2024-03-22 21:30 ` anlauf at gcc dot gnu.org
@ 2024-04-02 17:49 ` anlauf at gcc dot gnu.org
7 siblings, 0 replies; 9+ messages in thread
From: anlauf at gcc dot gnu.org @ 2024-04-02 17:49 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104848
anlauf at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |DUPLICATE
Status|NEW |RESOLVED
--- Comment #8 from anlauf at gcc dot gnu.org ---
The remaining issues are covered by pr99852.
*** This bug has been marked as a duplicate of bug 99852 ***
^ permalink raw reply [flat|nested] 9+ messages in thread