* [Bug fortran/103138] [12 Regression] ICE in gfc_simplify_cshift, at fortran/simplify.c:2139
2021-11-08 18:38 [Bug fortran/103138] New: [12 Regression] ICE in gfc_simplify_cshift, at fortran/simplify.c:2139 gscfq@t-online.de
@ 2021-11-08 20:40 ` anlauf at gcc dot gnu.org
2021-11-08 22:17 ` anlauf at gcc dot gnu.org
` (11 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: anlauf at gcc dot gnu.org @ 2021-11-08 20:40 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103138
anlauf at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |anlauf at gcc dot gnu.org
Ever confirmed|0 |1
Last reconfirmed| |2021-11-08
Status|UNCONFIRMED |NEW
--- Comment #1 from anlauf at gcc dot gnu.org ---
Naive patch:
diff --git a/gcc/fortran/simplify.c b/gcc/fortran/simplify.c
index d675f2c3aef..6cce7703667 100644
--- a/gcc/fortran/simplify.c
+++ b/gcc/fortran/simplify.c
@@ -2109,6 +2109,9 @@ gfc_simplify_cshift (gfc_expr *array, gfc_expr *shift,
gfc_expr *dim)
else
which = 0;
+ if (array->shape == NULL)
+ return NULL;
+
gfc_array_size (array, &size);
arraysize = mpz_get_ui (size);
mpz_clear (size);
However, this leads to a bogus error for the testcase:
pr103138.f90:5:31:
5 | integer, parameter :: b(2) = cshift(a, 1)
| 1
Error: transformational intrinsic 'cshift' at (1) is not permitted in an
initialization expression
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug fortran/103138] [12 Regression] ICE in gfc_simplify_cshift, at fortran/simplify.c:2139
2021-11-08 18:38 [Bug fortran/103138] New: [12 Regression] ICE in gfc_simplify_cshift, at fortran/simplify.c:2139 gscfq@t-online.de
2021-11-08 20:40 ` [Bug fortran/103138] " anlauf at gcc dot gnu.org
@ 2021-11-08 22:17 ` anlauf at gcc dot gnu.org
2021-11-09 8:33 ` [Bug fortran/103138] [12 Regression] ICE in gfc_simplify_cshift, at fortran/simplify.c:2139 since r12-4967-gbcf3728abe848888 marxin at gcc dot gnu.org
` (10 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: anlauf at gcc dot gnu.org @ 2021-11-08 22:17 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103138
--- Comment #2 from anlauf at gcc dot gnu.org ---
There are more testcases also with valid code which would ICE when using
CLASS and PARAMETER, or are rejected. See also pr103137.
Another one:
program p
type t
end type
class(t), parameter :: a(2) = t()
integer, parameter :: c(1) = shape (a)
end
The resulting ICE can be fixed,
--- a/gcc/fortran/check.c
+++ b/gcc/fortran/check.c
@@ -5096,6 +5106,9 @@ gfc_check_shape (gfc_expr *source, gfc_expr *kind)
if (source->rank == 0 || source->expr_type != EXPR_VARIABLE)
return true;
+ if (source->ref == NULL)
+ return false;
+
ar = gfc_find_array_ref (source);
if (ar->as && ar->as->type == AS_ASSUMED_SIZE && ar->type == AR_FULL)
but this gives a bogus error message.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug fortran/103138] [12 Regression] ICE in gfc_simplify_cshift, at fortran/simplify.c:2139 since r12-4967-gbcf3728abe848888
2021-11-08 18:38 [Bug fortran/103138] New: [12 Regression] ICE in gfc_simplify_cshift, at fortran/simplify.c:2139 gscfq@t-online.de
2021-11-08 20:40 ` [Bug fortran/103138] " anlauf at gcc dot gnu.org
2021-11-08 22:17 ` anlauf at gcc dot gnu.org
@ 2021-11-09 8:33 ` marxin at gcc dot gnu.org
2021-11-09 11:24 ` rguenth at gcc dot gnu.org
` (9 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: marxin at gcc dot gnu.org @ 2021-11-09 8:33 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103138
Martin Liška <marxin at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|[12 Regression] ICE in |[12 Regression] ICE in
|gfc_simplify_cshift, at |gfc_simplify_cshift, at
|fortran/simplify.c:2139 |fortran/simplify.c:2139
| |since
| |r12-4967-gbcf3728abe848888
CC| |marxin at gcc dot gnu.org
--- Comment #3 from Martin Liška <marxin at gcc dot gnu.org> ---
Started with r12-4967-gbcf3728abe848888.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug fortran/103138] [12 Regression] ICE in gfc_simplify_cshift, at fortran/simplify.c:2139 since r12-4967-gbcf3728abe848888
2021-11-08 18:38 [Bug fortran/103138] New: [12 Regression] ICE in gfc_simplify_cshift, at fortran/simplify.c:2139 gscfq@t-online.de
` (2 preceding siblings ...)
2021-11-09 8:33 ` [Bug fortran/103138] [12 Regression] ICE in gfc_simplify_cshift, at fortran/simplify.c:2139 since r12-4967-gbcf3728abe848888 marxin at gcc dot gnu.org
@ 2021-11-09 11:24 ` rguenth at gcc dot gnu.org
2021-11-10 19:42 ` cvs-commit at gcc dot gnu.org
` (8 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-11-09 11:24 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103138
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Priority|P3 |P4
Target Milestone|--- |12.0
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug fortran/103138] [12 Regression] ICE in gfc_simplify_cshift, at fortran/simplify.c:2139 since r12-4967-gbcf3728abe848888
2021-11-08 18:38 [Bug fortran/103138] New: [12 Regression] ICE in gfc_simplify_cshift, at fortran/simplify.c:2139 gscfq@t-online.de
` (3 preceding siblings ...)
2021-11-09 11:24 ` rguenth at gcc dot gnu.org
@ 2021-11-10 19:42 ` cvs-commit at gcc dot gnu.org
2021-11-11 20:17 ` cvs-commit at gcc dot gnu.org
` (7 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-11-10 19:42 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103138
--- Comment #4 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:abc2f01914d6c4703de26c402fb579a9a2d0dba4
commit r12-5136-gabc2f01914d6c4703de26c402fb579a9a2d0dba4
Author: Harald Anlauf <anlauf@gmx.de>
Date: Wed Nov 10 20:30:27 2021 +0100
Fortran: avoid NULL pointer dereferences
CLASS(), PARAMETER is not yet properly implemented in gfortran. Using it
in declarations could lead to subsequent NULL pointer dereferences during
checking or simplification of expressions involving those CLASS variables.
gcc/fortran/ChangeLog:
PR fortran/103137
PR fortran/103138
* check.c (gfc_check_shape): Avoid NULL pointer dereference on
missing ref.
* simplify.c (gfc_simplify_cshift): Avoid NULL pointer dereference
when shape not set.
(gfc_simplify_transpose): Likewise.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug fortran/103138] [12 Regression] ICE in gfc_simplify_cshift, at fortran/simplify.c:2139 since r12-4967-gbcf3728abe848888
2021-11-08 18:38 [Bug fortran/103138] New: [12 Regression] ICE in gfc_simplify_cshift, at fortran/simplify.c:2139 gscfq@t-online.de
` (4 preceding siblings ...)
2021-11-10 19:42 ` cvs-commit at gcc dot gnu.org
@ 2021-11-11 20:17 ` cvs-commit at gcc dot gnu.org
2021-11-13 20:15 ` cvs-commit at gcc dot gnu.org
` (6 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-11-11 20:17 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103138
--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-11 branch has been updated by Harald Anlauf
<anlauf@gcc.gnu.org>:
https://gcc.gnu.org/g:9ccc4f79f1a6dd08437e10db729694a744abb10a
commit r11-9235-g9ccc4f79f1a6dd08437e10db729694a744abb10a
Author: Harald Anlauf <anlauf@gmx.de>
Date: Wed Nov 10 20:30:27 2021 +0100
Fortran: avoid NULL pointer dereferences
CLASS(), PARAMETER is not yet properly implemented in gfortran. Using it
in declarations could lead to subsequent NULL pointer dereferences during
checking or simplification of expressions involving those CLASS variables.
gcc/fortran/ChangeLog:
PR fortran/103137
PR fortran/103138
* check.c (gfc_check_shape): Avoid NULL pointer dereference on
missing ref.
* simplify.c (gfc_simplify_cshift): Avoid NULL pointer dereference
when shape not set.
(gfc_simplify_transpose): Likewise.
(cherry picked from commit abc2f01914d6c4703de26c402fb579a9a2d0dba4)
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug fortran/103138] [12 Regression] ICE in gfc_simplify_cshift, at fortran/simplify.c:2139 since r12-4967-gbcf3728abe848888
2021-11-08 18:38 [Bug fortran/103138] New: [12 Regression] ICE in gfc_simplify_cshift, at fortran/simplify.c:2139 gscfq@t-online.de
` (5 preceding siblings ...)
2021-11-11 20:17 ` cvs-commit at gcc dot gnu.org
@ 2021-11-13 20:15 ` cvs-commit at gcc dot gnu.org
2022-05-06 8:31 ` [Bug fortran/103138] [12/13 " jakub at gcc dot gnu.org
` (5 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-11-13 20:15 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103138
--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-10 branch has been updated by Harald Anlauf
<anlauf@gcc.gnu.org>:
https://gcc.gnu.org/g:651d84ae6cb4299ea91c701ff8d9a7c67e076570
commit r10-10272-g651d84ae6cb4299ea91c701ff8d9a7c67e076570
Author: Harald Anlauf <anlauf@gmx.de>
Date: Wed Nov 10 20:30:27 2021 +0100
Fortran: avoid NULL pointer dereferences
CLASS(), PARAMETER is not yet properly implemented in gfortran. Using it
in declarations could lead to subsequent NULL pointer dereferences during
checking or simplification of expressions involving those CLASS variables.
gcc/fortran/ChangeLog:
PR fortran/103137
PR fortran/103138
* check.c (gfc_check_shape): Avoid NULL pointer dereference on
missing ref.
* simplify.c (gfc_simplify_cshift): Avoid NULL pointer dereference
when shape not set.
(gfc_simplify_transpose): Likewise.
(cherry picked from commit abc2f01914d6c4703de26c402fb579a9a2d0dba4)
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug fortran/103138] [12/13 Regression] ICE in gfc_simplify_cshift, at fortran/simplify.c:2139 since r12-4967-gbcf3728abe848888
2021-11-08 18:38 [Bug fortran/103138] New: [12 Regression] ICE in gfc_simplify_cshift, at fortran/simplify.c:2139 gscfq@t-online.de
` (6 preceding siblings ...)
2021-11-13 20:15 ` cvs-commit at gcc dot gnu.org
@ 2022-05-06 8:31 ` jakub at gcc dot gnu.org
2022-06-30 19:01 ` cvs-commit at gcc dot gnu.org
` (4 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: jakub at gcc dot gnu.org @ 2022-05-06 8:31 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103138
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|12.0 |12.2
--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
GCC 12.1 is being released, retargeting bugs to GCC 12.2.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug fortran/103138] [12/13 Regression] ICE in gfc_simplify_cshift, at fortran/simplify.c:2139 since r12-4967-gbcf3728abe848888
2021-11-08 18:38 [Bug fortran/103138] New: [12 Regression] ICE in gfc_simplify_cshift, at fortran/simplify.c:2139 gscfq@t-online.de
` (7 preceding siblings ...)
2022-05-06 8:31 ` [Bug fortran/103138] [12/13 " jakub at gcc dot gnu.org
@ 2022-06-30 19:01 ` cvs-commit at gcc dot gnu.org
2022-07-03 19:44 ` cvs-commit at gcc dot gnu.org
` (3 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-06-30 19:01 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103138
--- Comment #8 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:4c233cabbe388a6b8957c1507e129090e9267ceb
commit r13-1370-g4c233cabbe388a6b8957c1507e129090e9267ceb
Author: Harald Anlauf <anlauf@gmx.de>
Date: Wed Jun 29 21:36:17 2022 +0200
Fortran: error recovery on invalid CLASS(), PARAMETER declarations
[PR105243]
gcc/fortran/ChangeLog:
PR fortran/103137
PR fortran/103138
PR fortran/103693
PR fortran/105243
* decl.cc (gfc_match_data_decl): Reject CLASS entity declaration
when it is given the PARAMETER attribute.
gcc/testsuite/ChangeLog:
PR fortran/103137
PR fortran/103138
PR fortran/103693
PR fortran/105243
* gfortran.dg/class_58.f90: Fix test.
* gfortran.dg/class_73.f90: New test.
Co-authored-by: Steven G. Kargl <kargl@gcc.gnu.org>
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug fortran/103138] [12/13 Regression] ICE in gfc_simplify_cshift, at fortran/simplify.c:2139 since r12-4967-gbcf3728abe848888
2021-11-08 18:38 [Bug fortran/103138] New: [12 Regression] ICE in gfc_simplify_cshift, at fortran/simplify.c:2139 gscfq@t-online.de
` (8 preceding siblings ...)
2022-06-30 19:01 ` cvs-commit at gcc dot gnu.org
@ 2022-07-03 19:44 ` cvs-commit at gcc dot gnu.org
2022-07-03 20:13 ` cvs-commit at gcc dot gnu.org
` (2 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-07-03 19:44 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103138
--- Comment #9 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-12 branch has been updated by Harald Anlauf
<anlauf@gcc.gnu.org>:
https://gcc.gnu.org/g:d870ce1a112c0cbdff6172346a4a164503d92573
commit r12-8544-gd870ce1a112c0cbdff6172346a4a164503d92573
Author: Harald Anlauf <anlauf@gmx.de>
Date: Wed Jun 29 21:36:17 2022 +0200
Fortran: error recovery on invalid CLASS(), PARAMETER declarations
[PR105243]
gcc/fortran/ChangeLog:
PR fortran/103137
PR fortran/103138
PR fortran/103693
PR fortran/105243
* decl.cc (gfc_match_data_decl): Reject CLASS entity declaration
when it is given the PARAMETER attribute.
gcc/testsuite/ChangeLog:
PR fortran/103137
PR fortran/103138
PR fortran/103693
PR fortran/105243
* gfortran.dg/class_58.f90: Fix test.
* gfortran.dg/class_73.f90: New test.
Co-authored-by: Steven G. Kargl <kargl@gcc.gnu.org>
(cherry picked from commit 4c233cabbe388a6b8957c1507e129090e9267ceb)
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug fortran/103138] [12/13 Regression] ICE in gfc_simplify_cshift, at fortran/simplify.c:2139 since r12-4967-gbcf3728abe848888
2021-11-08 18:38 [Bug fortran/103138] New: [12 Regression] ICE in gfc_simplify_cshift, at fortran/simplify.c:2139 gscfq@t-online.de
` (9 preceding siblings ...)
2022-07-03 19:44 ` cvs-commit at gcc dot gnu.org
@ 2022-07-03 20:13 ` cvs-commit at gcc dot gnu.org
2022-07-03 20:29 ` cvs-commit at gcc dot gnu.org
2022-07-03 20:31 ` anlauf at gcc dot gnu.org
12 siblings, 0 replies; 14+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-07-03 20:13 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103138
--- Comment #10 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-11 branch has been updated by Harald Anlauf
<anlauf@gcc.gnu.org>:
https://gcc.gnu.org/g:5c293d9abc4b14e987a574fc11666809a2b8b8da
commit r11-10107-g5c293d9abc4b14e987a574fc11666809a2b8b8da
Author: Harald Anlauf <anlauf@gmx.de>
Date: Wed Jun 29 21:36:17 2022 +0200
Fortran: error recovery on invalid CLASS(), PARAMETER declarations
[PR105243]
gcc/fortran/ChangeLog:
PR fortran/103137
PR fortran/103138
PR fortran/103693
PR fortran/105243
* decl.c (gfc_match_data_decl): Reject CLASS entity declaration
when it is given the PARAMETER attribute.
gcc/testsuite/ChangeLog:
PR fortran/103137
PR fortran/103138
PR fortran/103693
PR fortran/105243
* gfortran.dg/class_58.f90: Fix test.
* gfortran.dg/class_73.f90: New test.
Co-authored-by: Steven G. Kargl <kargl@gcc.gnu.org>
(cherry picked from commit 4c233cabbe388a6b8957c1507e129090e9267ceb)
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug fortran/103138] [12/13 Regression] ICE in gfc_simplify_cshift, at fortran/simplify.c:2139 since r12-4967-gbcf3728abe848888
2021-11-08 18:38 [Bug fortran/103138] New: [12 Regression] ICE in gfc_simplify_cshift, at fortran/simplify.c:2139 gscfq@t-online.de
` (10 preceding siblings ...)
2022-07-03 20:13 ` cvs-commit at gcc dot gnu.org
@ 2022-07-03 20:29 ` cvs-commit at gcc dot gnu.org
2022-07-03 20:31 ` anlauf at gcc dot gnu.org
12 siblings, 0 replies; 14+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-07-03 20:29 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103138
--- Comment #11 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-10 branch has been updated by Harald Anlauf
<anlauf@gcc.gnu.org>:
https://gcc.gnu.org/g:290147c4c8e3d9d1f13297b511d3a0afb5e952d4
commit r10-10882-g290147c4c8e3d9d1f13297b511d3a0afb5e952d4
Author: Harald Anlauf <anlauf@gmx.de>
Date: Wed Jun 29 21:36:17 2022 +0200
Fortran: error recovery on invalid CLASS(), PARAMETER declarations
[PR105243]
gcc/fortran/ChangeLog:
PR fortran/103137
PR fortran/103138
PR fortran/103693
PR fortran/105243
* decl.c (gfc_match_data_decl): Reject CLASS entity declaration
when it is given the PARAMETER attribute.
gcc/testsuite/ChangeLog:
PR fortran/103137
PR fortran/103138
PR fortran/103693
PR fortran/105243
* gfortran.dg/class_58.f90: Fix test.
* gfortran.dg/class_73.f90: New test.
Co-authored-by: Steven G. Kargl <kargl@gcc.gnu.org>
(cherry picked from commit 4c233cabbe388a6b8957c1507e129090e9267ceb)
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug fortran/103138] [12/13 Regression] ICE in gfc_simplify_cshift, at fortran/simplify.c:2139 since r12-4967-gbcf3728abe848888
2021-11-08 18:38 [Bug fortran/103138] New: [12 Regression] ICE in gfc_simplify_cshift, at fortran/simplify.c:2139 gscfq@t-online.de
` (11 preceding siblings ...)
2022-07-03 20:29 ` cvs-commit at gcc dot gnu.org
@ 2022-07-03 20:31 ` anlauf at gcc dot gnu.org
12 siblings, 0 replies; 14+ messages in thread
From: anlauf at gcc dot gnu.org @ 2022-07-03 20:31 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103138
anlauf at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Target Milestone|12.2 |10.5
Resolution|--- |FIXED
--- Comment #12 from anlauf at gcc dot gnu.org ---
Fixed on all open branches. Closing.
Thanks for the report!
^ permalink raw reply [flat|nested] 14+ messages in thread