public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/107680] New: ICE in arith_power, at fortran/arith.cc:989 and :1006
@ 2022-11-14 17:26 gscfq@t-online.de
2022-11-14 18:23 ` [Bug fortran/107680] " anlauf at gcc dot gnu.org
` (7 more replies)
0 siblings, 8 replies; 9+ messages in thread
From: gscfq@t-online.de @ 2022-11-14 17:26 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107680
Bug ID: 107680
Summary: ICE in arith_power, at fortran/arith.cc:989 and :1006
Product: gcc
Version: 13.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: gscfq@t-online.de
Target Milestone: ---
Affects versions down to at least r5 :
$ cat z1.f90
program p
print *, [real :: ([1])] ** 2.0
end
$ cat z2.f90
program p
print *, [complex :: ([1])] ** 2.0
end
$ cat z3.f90
program p
print *, [complex :: ([1])] ** (1.0,2.0)
end
$ gfortran-13-20221106 -c z1.f90
f951: internal compiler error: Segmentation fault
0xf4697f crash_signal
../../gcc/toplev.cc:314
0x7c4b87 arith_power
../../gcc/fortran/arith.cc:989
0x7c2ce9 reduce_binary_ac
../../gcc/fortran/arith.cc:1365
0x7c2d3e reduce_binary_ac
../../gcc/fortran/arith.cc:1369
0x7c2f9f reduce_binary
../../gcc/fortran/arith.cc:1520
0x7c33d2 eval_intrinsic
../../gcc/fortran/arith.cc:1701
0x835df6 match_mult_operand
../../gcc/fortran/matchexp.cc:288
0x835f98 match_add_operand
../../gcc/fortran/matchexp.cc:356
0x8361ec match_level_2
../../gcc/fortran/matchexp.cc:480
0x836342 match_level_3
../../gcc/fortran/matchexp.cc:551
0x836434 match_level_4
../../gcc/fortran/matchexp.cc:599
0x836434 match_and_operand
../../gcc/fortran/matchexp.cc:693
0x836622 match_or_operand
../../gcc/fortran/matchexp.cc:722
0x8366f2 match_equiv_operand
../../gcc/fortran/matchexp.cc:765
0x8367c4 match_level_5
../../gcc/fortran/matchexp.cc:811
0x835b91 gfc_match_expr(gfc_expr**)
../../gcc/fortran/matchexp.cc:870
0x81d289 match_io_element
../../gcc/fortran/io.cc:3668
0x81fbba match_io_list
../../gcc/fortran/io.cc:3716
0x81ffbe match_io
../../gcc/fortran/io.cc:4394
0x823aba gfc_match_print()
../../gcc/fortran/io.cc:4450
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug fortran/107680] ICE in arith_power, at fortran/arith.cc:989 and :1006
2022-11-14 17:26 [Bug fortran/107680] New: ICE in arith_power, at fortran/arith.cc:989 and :1006 gscfq@t-online.de
@ 2022-11-14 18:23 ` anlauf at gcc dot gnu.org
2022-11-14 21:44 ` 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-11-14 18:23 UTC (permalink / raw)
To: 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.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug fortran/107680] ICE in arith_power, at fortran/arith.cc:989 and :1006
2022-11-14 17:26 [Bug fortran/107680] New: ICE in arith_power, at fortran/arith.cc:989 and :1006 gscfq@t-online.de
2022-11-14 18:23 ` [Bug fortran/107680] " anlauf at gcc dot gnu.org
@ 2022-11-14 21:44 ` anlauf at gcc dot gnu.org
2022-11-15 10:18 ` mikael at gcc dot gnu.org
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: anlauf at gcc dot gnu.org @ 2022-11-14 21:44 UTC (permalink / raw)
To: 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 (&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);
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug fortran/107680] ICE in arith_power, at fortran/arith.cc:989 and :1006
2022-11-14 17:26 [Bug fortran/107680] New: ICE in arith_power, at fortran/arith.cc:989 and :1006 gscfq@t-online.de
2022-11-14 18:23 ` [Bug fortran/107680] " anlauf at gcc dot gnu.org
2022-11-14 21:44 ` anlauf at gcc dot gnu.org
@ 2022-11-15 10:18 ` mikael at gcc dot gnu.org
2022-11-15 19:34 ` anlauf at gcc dot gnu.org
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: mikael at gcc dot gnu.org @ 2022-11-15 10:18 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107680
Mikael Morin <mikael at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |mikael at gcc dot gnu.org
--- Comment #3 from Mikael Morin <mikael at gcc dot gnu.org> ---
I thought the call to gfc_type_convert_binary in eval_intrinsic was taking care
of mismatching types, doesn't it?
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug fortran/107680] ICE in arith_power, at fortran/arith.cc:989 and :1006
2022-11-14 17:26 [Bug fortran/107680] New: ICE in arith_power, at fortran/arith.cc:989 and :1006 gscfq@t-online.de
` (2 preceding siblings ...)
2022-11-15 10:18 ` mikael at gcc dot gnu.org
@ 2022-11-15 19:34 ` anlauf at gcc dot gnu.org
2022-11-15 20:45 ` 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-11-15 19:34 UTC (permalink / raw)
To: 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.00000000
for all versions <= 12, and
9.00000000
for mainline.
Given these observations, I suspect that typespecs are not consistently
handled... See also the previous discussions.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug fortran/107680] ICE in arith_power, at fortran/arith.cc:989 and :1006
2022-11-14 17:26 [Bug fortran/107680] New: ICE in arith_power, at fortran/arith.cc:989 and :1006 gscfq@t-online.de
` (3 preceding siblings ...)
2022-11-15 19:34 ` anlauf at gcc dot gnu.org
@ 2022-11-15 20:45 ` anlauf at gcc dot gnu.org
2022-11-16 20:17 ` cvs-commit at gcc dot gnu.org
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: anlauf at gcc dot gnu.org @ 2022-11-15 20:45 UTC (permalink / raw)
To: 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
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug fortran/107680] ICE in arith_power, at fortran/arith.cc:989 and :1006
2022-11-14 17:26 [Bug fortran/107680] New: ICE in arith_power, at fortran/arith.cc:989 and :1006 gscfq@t-online.de
` (4 preceding siblings ...)
2022-11-15 20:45 ` anlauf at gcc dot gnu.org
@ 2022-11-16 20:17 ` cvs-commit at gcc dot gnu.org
2022-11-18 18:29 ` anlauf at gcc dot gnu.org
2022-11-28 22:29 ` pinskia at gcc dot gnu.org
7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-11-16 20:17 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107680
--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Harald Anlauf <anlauf@gcc.gnu.org>:
https://gcc.gnu.org/g:713dcfc85ebbabaf74a1bcbac4ba1143519b31d6
commit r13-4106-g713dcfc85ebbabaf74a1bcbac4ba1143519b31d6
Author: Harald Anlauf <anlauf@gmx.de>
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.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug fortran/107680] ICE in arith_power, at fortran/arith.cc:989 and :1006
2022-11-14 17:26 [Bug fortran/107680] New: ICE in arith_power, at fortran/arith.cc:989 and :1006 gscfq@t-online.de
` (5 preceding siblings ...)
2022-11-16 20:17 ` cvs-commit at gcc dot gnu.org
@ 2022-11-18 18:29 ` anlauf at gcc dot gnu.org
2022-11-28 22:29 ` pinskia at gcc dot gnu.org
7 siblings, 0 replies; 9+ messages in thread
From: anlauf at gcc dot gnu.org @ 2022-11-18 18:29 UTC (permalink / raw)
To: 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!
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug fortran/107680] ICE in arith_power, at fortran/arith.cc:989 and :1006
2022-11-14 17:26 [Bug fortran/107680] New: ICE in arith_power, at fortran/arith.cc:989 and :1006 gscfq@t-online.de
` (6 preceding siblings ...)
2022-11-18 18:29 ` anlauf at gcc dot gnu.org
@ 2022-11-28 22:29 ` pinskia at gcc dot gnu.org
7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-11-28 22:29 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107680
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |13.0
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2022-11-28 22:29 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-14 17:26 [Bug fortran/107680] New: ICE in arith_power, at fortran/arith.cc:989 and :1006 gscfq@t-online.de
2022-11-14 18:23 ` [Bug fortran/107680] " anlauf at gcc dot gnu.org
2022-11-14 21:44 ` anlauf at gcc dot gnu.org
2022-11-15 10:18 ` mikael at gcc dot gnu.org
2022-11-15 19:34 ` anlauf at gcc dot gnu.org
2022-11-15 20:45 ` anlauf at gcc dot gnu.org
2022-11-16 20:17 ` cvs-commit at gcc dot gnu.org
2022-11-18 18:29 ` anlauf at gcc dot gnu.org
2022-11-28 22:29 ` pinskia at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).