public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/106209] New: ICE in add_init_expr_to_sym, at fortran/decl.cc:2132
@ 2022-07-05 18:49 gscfq@t-online.de
2022-07-05 19:21 ` [Bug fortran/106209] " kargl at gcc dot gnu.org
` (7 more replies)
0 siblings, 8 replies; 9+ messages in thread
From: gscfq@t-online.de @ 2022-07-05 18:49 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106209
Bug ID: 106209
Summary: ICE in add_init_expr_to_sym, at fortran/decl.cc:2132
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
integer, parameter :: a(:) = 0
integer, parameter :: b(*) = a
end
$ cat z2.f90
program p
integer, parameter :: a(:) = 0
integer, parameter :: b(*) = [a]
end
$ gfortran-13-20220703 -c z1.f90
f951: internal compiler error: in add_init_expr_to_sym, at fortran/decl.cc:2132
0x6e225e add_init_expr_to_sym
../../gcc/fortran/decl.cc:2132
0x6ebe06 variable_decl
../../gcc/fortran/decl.cc:3120
0x6ebe06 gfc_match_data_decl()
../../gcc/fortran/decl.cc:6319
0x757723 match_word
../../gcc/fortran/parse.cc:67
0x757723 decode_statement
../../gcc/fortran/parse.cc:378
0x75916a next_free
../../gcc/fortran/parse.cc:1397
0x75916a next_statement
../../gcc/fortran/parse.cc:1629
0x75a6fb parse_spec
../../gcc/fortran/parse.cc:4168
0x75d89c parse_progunit
../../gcc/fortran/parse.cc:6210
0x75ef61 gfc_parse_file()
../../gcc/fortran/parse.cc:6755
0x7acb3f gfc_be_parse_file
../../gcc/fortran/f95-lang.cc:229
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug fortran/106209] ICE in add_init_expr_to_sym, at fortran/decl.cc:2132
2022-07-05 18:49 [Bug fortran/106209] New: ICE in add_init_expr_to_sym, at fortran/decl.cc:2132 gscfq@t-online.de
@ 2022-07-05 19:21 ` kargl at gcc dot gnu.org
2022-07-14 19:35 ` anlauf at gcc dot gnu.org
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: kargl at gcc dot gnu.org @ 2022-07-05 19:21 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106209
kargl at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed| |2022-07-05
Status|UNCONFIRMED |NEW
Ever confirmed|0 |1
CC| |kargl at gcc dot gnu.org
Priority|P3 |P4
--- Comment #1 from kargl at gcc dot gnu.org ---
Instead of an assert(), simply return false to give gfortran a chance to emit
an error.
% gfcx -c a.f90
a.f90:3:4:
3 | integer, parameter :: b(*) = a
| 1
Error: Unclassifiable statement at (1)
a.f90:2:29:
2 | integer, parameter :: a(:) = 0
| 1
Error: Parameter array 'a' at (1) cannot be automatic or of deferred shape
diff --git a/gcc/fortran/decl.cc b/gcc/fortran/decl.cc
index bd586e75008..cec178fc80b 100644
--- a/gcc/fortran/decl.cc
+++ b/gcc/fortran/decl.cc
@@ -2129,7 +2129,9 @@ add_init_expr_to_sym (const char *name, gfc_expr **initp,
locus *var_locus)
/* The shape may be NULL for EXPR_ARRAY, set it. */
if (init->shape == NULL)
{
- gcc_assert (init->expr_type == EXPR_ARRAY);
+ if (init->expr_type != EXPR_ARRAY)
+ return false;
+
init->shape = gfc_get_shape (1);
if (!gfc_array_size (init, &init->shape[0]))
gfc_internal_error ("gfc_array_size failed");
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug fortran/106209] ICE in add_init_expr_to_sym, at fortran/decl.cc:2132
2022-07-05 18:49 [Bug fortran/106209] New: ICE in add_init_expr_to_sym, at fortran/decl.cc:2132 gscfq@t-online.de
2022-07-05 19:21 ` [Bug fortran/106209] " kargl at gcc dot gnu.org
@ 2022-07-14 19:35 ` anlauf at gcc dot gnu.org
2022-07-14 20:17 ` sgk at troutmask dot apl.washington.edu
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: anlauf at gcc dot gnu.org @ 2022-07-14 19:35 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106209
anlauf at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |anlauf at gcc dot gnu.org
--- Comment #2 from anlauf at gcc dot gnu.org ---
(In reply to kargl from comment #1)
> Instead of an assert(), simply return false to give gfortran a chance to
> emit an error.
Steve, your patch does fix z1, but not z2, which hits the
gfc_internal_error ("gfc_array_size failed");
a few lines later...
The following adjusted patch fixes the latter, too, regtests cleanly,
and gives nicer error messages :)
diff --git a/gcc/fortran/decl.cc b/gcc/fortran/decl.cc
index 339f8b15035..b6400514731 100644
--- a/gcc/fortran/decl.cc
+++ b/gcc/fortran/decl.cc
@@ -2129,10 +2129,21 @@ add_init_expr_to_sym (const char *name, gfc_expr
**initp, locus *var_
locus)
/* The shape may be NULL for EXPR_ARRAY, set it. */
if (init->shape == NULL)
{
- gcc_assert (init->expr_type == EXPR_ARRAY);
+ if (init->expr_type != EXPR_ARRAY)
+ {
+ gfc_error ("Bad shape of initializer at %L", &init->where);
+ return false;
+ }
+
init->shape = gfc_get_shape (1);
if (!gfc_array_size (init, &init->shape[0]))
- gfc_internal_error ("gfc_array_size failed");
+ {
+ gfc_error ("Cannot determine shape of initializer at %L",
+ &init->where);
+ free (init->shape);
+ init->shape = NULL;
+ return false;
+ }
}
for (dim = 0; dim < sym->as->rank; ++dim)
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug fortran/106209] ICE in add_init_expr_to_sym, at fortran/decl.cc:2132
2022-07-05 18:49 [Bug fortran/106209] New: ICE in add_init_expr_to_sym, at fortran/decl.cc:2132 gscfq@t-online.de
2022-07-05 19:21 ` [Bug fortran/106209] " kargl at gcc dot gnu.org
2022-07-14 19:35 ` anlauf at gcc dot gnu.org
@ 2022-07-14 20:17 ` sgk at troutmask dot apl.washington.edu
2022-07-14 20:27 ` cvs-commit at gcc dot gnu.org
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: sgk at troutmask dot apl.washington.edu @ 2022-07-14 20:17 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106209
--- Comment #3 from Steve Kargl <sgk at troutmask dot apl.washington.edu> ---
On Thu, Jul 14, 2022 at 07:35:21PM +0000, anlauf at gcc dot gnu.org wrote:
>
> --- Comment #2 from anlauf at gcc dot gnu.org ---
> (In reply to kargl from comment #1)
> > Instead of an assert(), simply return false to give gfortran a chance to
> > emit an error.
>
> Steve, your patch does fix z1, but not z2, which hits the
>
> gfc_internal_error ("gfc_array_size failed");
Sorry about that. Your patch looks good to me.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug fortran/106209] ICE in add_init_expr_to_sym, at fortran/decl.cc:2132
2022-07-05 18:49 [Bug fortran/106209] New: ICE in add_init_expr_to_sym, at fortran/decl.cc:2132 gscfq@t-online.de
` (2 preceding siblings ...)
2022-07-14 20:17 ` sgk at troutmask dot apl.washington.edu
@ 2022-07-14 20:27 ` cvs-commit at gcc dot gnu.org
2022-07-14 20:36 ` anlauf at gcc dot gnu.org
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-07-14 20:27 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106209
--- 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:748f8a8b145dde59c7b63aa68b5a59515b7efc49
commit r13-1698-g748f8a8b145dde59c7b63aa68b5a59515b7efc49
Author: Harald Anlauf <anlauf@gmx.de>
Date: Thu Jul 14 22:24:55 2022 +0200
Fortran: error recovery for bad initializers of implied-shape arrays
[PR106209]
gcc/fortran/ChangeLog:
PR fortran/106209
* decl.cc (add_init_expr_to_sym): Handle bad initializers for
implied-shape arrays.
gcc/testsuite/ChangeLog:
PR fortran/106209
* gfortran.dg/pr106209.f90: New test.
Co-authored-by: Steven G. Kargl <kargl@gcc.gnu.org>
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug fortran/106209] ICE in add_init_expr_to_sym, at fortran/decl.cc:2132
2022-07-05 18:49 [Bug fortran/106209] New: ICE in add_init_expr_to_sym, at fortran/decl.cc:2132 gscfq@t-online.de
` (3 preceding siblings ...)
2022-07-14 20:27 ` cvs-commit at gcc dot gnu.org
@ 2022-07-14 20:36 ` anlauf at gcc dot gnu.org
2023-01-28 22:03 ` 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-07-14 20:36 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106209
anlauf at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution|--- |FIXED
--- Comment #5 from anlauf at gcc dot gnu.org ---
Fixed for gcc-13.
Thanks for the report!
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug fortran/106209] ICE in add_init_expr_to_sym, at fortran/decl.cc:2132
2022-07-05 18:49 [Bug fortran/106209] New: ICE in add_init_expr_to_sym, at fortran/decl.cc:2132 gscfq@t-online.de
` (4 preceding siblings ...)
2022-07-14 20:36 ` anlauf at gcc dot gnu.org
@ 2023-01-28 22:03 ` cvs-commit at gcc dot gnu.org
2023-02-04 15:43 ` cvs-commit at gcc dot gnu.org
2023-02-05 18:55 ` cvs-commit at gcc dot gnu.org
7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-01-28 22:03 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106209
--- Comment #6 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:6dc4f984dd14ffad34e0540f2030f553579adefd
commit r12-9079-g6dc4f984dd14ffad34e0540f2030f553579adefd
Author: Harald Anlauf <anlauf@gmx.de>
Date: Thu Jul 14 22:24:55 2022 +0200
Fortran: error recovery for bad initializers of implied-shape arrays
[PR106209]
gcc/fortran/ChangeLog:
PR fortran/106209
* decl.cc (add_init_expr_to_sym): Handle bad initializers for
implied-shape arrays.
gcc/testsuite/ChangeLog:
PR fortran/106209
* gfortran.dg/pr106209.f90: New test.
Co-authored-by: Steven G. Kargl <kargl@gcc.gnu.org>
(cherry picked from commit 748f8a8b145dde59c7b63aa68b5a59515b7efc49)
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug fortran/106209] ICE in add_init_expr_to_sym, at fortran/decl.cc:2132
2022-07-05 18:49 [Bug fortran/106209] New: ICE in add_init_expr_to_sym, at fortran/decl.cc:2132 gscfq@t-online.de
` (5 preceding siblings ...)
2023-01-28 22:03 ` cvs-commit at gcc dot gnu.org
@ 2023-02-04 15:43 ` cvs-commit at gcc dot gnu.org
2023-02-05 18:55 ` cvs-commit at gcc dot gnu.org
7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-02-04 15:43 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106209
--- Comment #7 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:8e58d94ac56127ebca3a893284455032a707d948
commit r11-10505-g8e58d94ac56127ebca3a893284455032a707d948
Author: Harald Anlauf <anlauf@gmx.de>
Date: Thu Jul 14 22:24:55 2022 +0200
Fortran: error recovery for bad initializers of implied-shape arrays
[PR106209]
gcc/fortran/ChangeLog:
PR fortran/106209
* decl.c (add_init_expr_to_sym): Handle bad initializers for
implied-shape arrays.
gcc/testsuite/ChangeLog:
PR fortran/106209
* gfortran.dg/pr106209.f90: New test.
Co-authored-by: Steven G. Kargl <kargl@gcc.gnu.org>
(cherry picked from commit 748f8a8b145dde59c7b63aa68b5a59515b7efc49)
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug fortran/106209] ICE in add_init_expr_to_sym, at fortran/decl.cc:2132
2022-07-05 18:49 [Bug fortran/106209] New: ICE in add_init_expr_to_sym, at fortran/decl.cc:2132 gscfq@t-online.de
` (6 preceding siblings ...)
2023-02-04 15:43 ` cvs-commit at gcc dot gnu.org
@ 2023-02-05 18:55 ` cvs-commit at gcc dot gnu.org
7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-02-05 18:55 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106209
--- Comment #8 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:b523b58690c84b04cc9695d2d652611beb6f28ca
commit r10-11197-gb523b58690c84b04cc9695d2d652611beb6f28ca
Author: Harald Anlauf <anlauf@gmx.de>
Date: Thu Jul 14 22:24:55 2022 +0200
Fortran: error recovery for bad initializers of implied-shape arrays
[PR106209]
gcc/fortran/ChangeLog:
PR fortran/106209
* decl.c (add_init_expr_to_sym): Handle bad initializers for
implied-shape arrays.
gcc/testsuite/ChangeLog:
PR fortran/106209
* gfortran.dg/pr106209.f90: New test.
Co-authored-by: Steven G. Kargl <kargl@gcc.gnu.org>
(cherry picked from commit 748f8a8b145dde59c7b63aa68b5a59515b7efc49)
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2023-02-05 18:55 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-05 18:49 [Bug fortran/106209] New: ICE in add_init_expr_to_sym, at fortran/decl.cc:2132 gscfq@t-online.de
2022-07-05 19:21 ` [Bug fortran/106209] " kargl at gcc dot gnu.org
2022-07-14 19:35 ` anlauf at gcc dot gnu.org
2022-07-14 20:17 ` sgk at troutmask dot apl.washington.edu
2022-07-14 20:27 ` cvs-commit at gcc dot gnu.org
2022-07-14 20:36 ` anlauf at gcc dot gnu.org
2023-01-28 22:03 ` cvs-commit at gcc dot gnu.org
2023-02-04 15:43 ` cvs-commit at gcc dot gnu.org
2023-02-05 18:55 ` cvs-commit 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).