public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/101327] New: ICE in find_array_element, at fortran/expr.c:1355
@ 2021-07-05 16:38 gscfq@t-online.de
  2021-07-06 17:50 ` [Bug fortran/101327] " kargl at gcc dot gnu.org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: gscfq@t-online.de @ 2021-07-05 16:38 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101327

            Bug ID: 101327
           Summary: ICE in find_array_element, at fortran/expr.c:1355
           Product: gcc
           Version: 12.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
subroutine s
   integer, parameter :: n([2]) = [1, 2]
   type t
      integer :: a(n(1):n(2))
   end type
end


$ gfortran-12-20210704 -c z1.f90
f951: internal compiler error: in find_array_element, at fortran/expr.c:1355
0x6fe17d find_array_element
        ../../gcc/fortran/expr.c:1354
0x6fe17d simplify_const_ref
        ../../gcc/fortran/expr.c:1882
0x6fe85e gfc_simplify_expr(gfc_expr*, int)
        ../../gcc/fortran/expr.c:2281
0x6feaab simplify_parameter_variable
        ../../gcc/fortran/expr.c:2110
0x6fe82d gfc_simplify_expr(gfc_expr*, int)
        ../../gcc/fortran/expr.c:2248
0x6ea784 variable_decl
        ../../gcc/fortran/decl.c:2640
0x6ea784 gfc_match_data_decl()
        ../../gcc/fortran/decl.c:6201
0x751bd3 match_word
        ../../gcc/fortran/parse.c:65
0x751bd3 decode_statement
        ../../gcc/fortran/parse.c:376
0x75361a next_free
        ../../gcc/fortran/parse.c:1351
0x75361a next_statement
        ../../gcc/fortran/parse.c:1583
0x755114 parse_derived
        ../../gcc/fortran/parse.c:3490
0x755114 parse_spec
        ../../gcc/fortran/parse.c:4031
0x757aac parse_progunit
        ../../gcc/fortran/parse.c:6009
0x759560 gfc_parse_file()
        ../../gcc/fortran/parse.c:6557
0x7a5c4f gfc_be_parse_file
        ../../gcc/fortran/f95-lang.c:216

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug fortran/101327] ICE in find_array_element, at fortran/expr.c:1355
  2021-07-05 16:38 [Bug fortran/101327] New: ICE in find_array_element, at fortran/expr.c:1355 gscfq@t-online.de
@ 2021-07-06 17:50 ` kargl at gcc dot gnu.org
  2021-08-30 19:35 ` anlauf at gcc dot gnu.org
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: kargl at gcc dot gnu.org @ 2021-07-06 17:50 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101327

kargl at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kargl at gcc dot gnu.org
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2021-07-06
             Status|UNCONFIRMED                 |NEW

--- Comment #1 from kargl at gcc dot gnu.org ---
diff --git a/gcc/fortran/expr.c b/gcc/fortran/expr.c
index b11ae7ce5c5..d370fba9616 100644
--- a/gcc/fortran/expr.c
+++ b/gcc/fortran/expr.c
@@ -1351,8 +1351,13 @@ find_array_element (gfc_constructor_base base,
gfc_array_ref *ar,
          goto depart;
        }

-      gcc_assert (ar->as->upper[i]->expr_type == EXPR_CONSTANT
-                 && ar->as->lower[i]->expr_type == EXPR_CONSTANT);
+      if (ar->as->upper[i]->expr_type != EXPR_CONSTANT
+         || ar->as->lower[i]->expr_type != EXPR_CONSTANT)
+       {
+         t = false;
+         cons = NULL;
+         goto depart;
+       }

       /* Check the bounds.  */
       if ((ar->as->upper[i]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug fortran/101327] ICE in find_array_element, at fortran/expr.c:1355
  2021-07-05 16:38 [Bug fortran/101327] New: ICE in find_array_element, at fortran/expr.c:1355 gscfq@t-online.de
  2021-07-06 17:50 ` [Bug fortran/101327] " kargl at gcc dot gnu.org
@ 2021-08-30 19:35 ` anlauf at gcc dot gnu.org
  2021-08-30 20:02 ` sgk at troutmask dot apl.washington.edu
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: anlauf at gcc dot gnu.org @ 2021-08-30 19:35 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101327

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 ---
Slightly more compact resulting code with:

diff --git a/gcc/fortran/expr.c b/gcc/fortran/expr.c
index 35563a78697..dfecc3012e1 100644
--- a/gcc/fortran/expr.c
+++ b/gcc/fortran/expr.c
@@ -1337,7 +1337,9 @@ find_array_element (gfc_constructor_base base,
gfc_array_ref *ar,
   for (i = 0; i < ar->dimen; i++)
     {
       if (!gfc_reduce_init_expr (ar->as->lower[i])
-         || !gfc_reduce_init_expr (ar->as->upper[i]))
+         || !gfc_reduce_init_expr (ar->as->upper[i])
+         || ar->as->upper[i]->expr_type != EXPR_CONSTANT
+         || ar->as->lower[i]->expr_type != EXPR_CONSTANT)
        {
          t = false;
          cons = NULL;
@@ -1351,9 +1353,6 @@ find_array_element (gfc_constructor_base base,
gfc_array_ref *ar,
          goto depart;
        }

-      gcc_assert (ar->as->upper[i]->expr_type == EXPR_CONSTANT
-                 && ar->as->lower[i]->expr_type == EXPR_CONSTANT);
-
       /* Check the bounds.  */
       if ((ar->as->upper[i]
           && mpz_cmp (e->value.integer,

Steve,

are you going to submit this or your version?

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug fortran/101327] ICE in find_array_element, at fortran/expr.c:1355
  2021-07-05 16:38 [Bug fortran/101327] New: ICE in find_array_element, at fortran/expr.c:1355 gscfq@t-online.de
  2021-07-06 17:50 ` [Bug fortran/101327] " kargl at gcc dot gnu.org
  2021-08-30 19:35 ` anlauf at gcc dot gnu.org
@ 2021-08-30 20:02 ` sgk at troutmask dot apl.washington.edu
  2021-08-30 20:13 ` anlauf at gcc dot gnu.org
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: sgk at troutmask dot apl.washington.edu @ 2021-08-30 20:02 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101327

--- Comment #3 from Steve Kargl <sgk at troutmask dot apl.washington.edu> ---
On Mon, Aug 30, 2021 at 07:35:17PM +0000, anlauf at gcc dot gnu.org wrote:
> 
> Steve,
> 
> are you going to submit this or your version?
> 

I no longer have the ability to commit changes,
so I won't being submitting patches to fortran@
and gcc-patches@ for review.  I'll simply add
patches to bug reports and move on.

My current method of development:

1) git clone humble into gccx/
2) Develop a patch and test patch.
3) git diff HEAD > prXXX.diff
4) Place diff into PR.
5) Repeat 2)-4) until gccx/ tree gets messed up
6) rm -rf gccx/ and goto 1)

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug fortran/101327] ICE in find_array_element, at fortran/expr.c:1355
  2021-07-05 16:38 [Bug fortran/101327] New: ICE in find_array_element, at fortran/expr.c:1355 gscfq@t-online.de
                   ` (2 preceding siblings ...)
  2021-08-30 20:02 ` sgk at troutmask dot apl.washington.edu
@ 2021-08-30 20:13 ` anlauf at gcc dot gnu.org
  2021-08-30 21:41 ` anlauf at gcc dot gnu.org
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: anlauf at gcc dot gnu.org @ 2021-08-30 20:13 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101327

--- Comment #4 from anlauf at gcc dot gnu.org ---
(In reply to Steve Kargl from comment #3)
> I no longer have the ability to commit changes,
> so I won't being submitting patches to fortran@
> and gcc-patches@ for review.  I'll simply add
> patches to bug reports and move on.

You rarely say whether the patch regtests fine.  Would be a nice-to-have.

> My current method of development:
> 
> 1) git clone humble into gccx/
> 2) Develop a patch and test patch.
> 3) git diff HEAD > prXXX.diff
> 4) Place diff into PR.
> 5) Repeat 2)-4) until gccx/ tree gets messed up
> 6) rm -rf gccx/ and goto 1)

Probably not the most common nor most efficient workflow when using git...

Anyway, the current patch is obvious enough.  I could commit it for you.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug fortran/101327] ICE in find_array_element, at fortran/expr.c:1355
  2021-07-05 16:38 [Bug fortran/101327] New: ICE in find_array_element, at fortran/expr.c:1355 gscfq@t-online.de
                   ` (3 preceding siblings ...)
  2021-08-30 20:13 ` anlauf at gcc dot gnu.org
@ 2021-08-30 21:41 ` anlauf at gcc dot gnu.org
  2021-09-07 18:52 ` cvs-commit at gcc dot gnu.org
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: anlauf at gcc dot gnu.org @ 2021-08-30 21:41 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101327

--- Comment #5 from anlauf at gcc dot gnu.org ---
Submitted: https://gcc.gnu.org/pipermail/fortran/2021-August/056455.html

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug fortran/101327] ICE in find_array_element, at fortran/expr.c:1355
  2021-07-05 16:38 [Bug fortran/101327] New: ICE in find_array_element, at fortran/expr.c:1355 gscfq@t-online.de
                   ` (4 preceding siblings ...)
  2021-08-30 21:41 ` anlauf at gcc dot gnu.org
@ 2021-09-07 18:52 ` cvs-commit at gcc dot gnu.org
  2021-09-11 19:01 ` cvs-commit at gcc dot gnu.org
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-09-07 18:52 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101327

--- 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:2a1537a19cb2fa85823cfa18ed40baa4b259b4e3

commit r12-3392-g2a1537a19cb2fa85823cfa18ed40baa4b259b4e3
Author: Harald Anlauf <anlauf@gmx.de>
Date:   Tue Sep 7 20:51:49 2021 +0200

    Fortran - improve error recovery determining array element from constructor

    gcc/fortran/ChangeLog:

            PR fortran/101327
            * expr.c (find_array_element): When bounds cannot be determined as
            constant, return error instead of aborting.

    gcc/testsuite/ChangeLog:

            PR fortran/101327
            * gfortran.dg/pr101327.f90: New test.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug fortran/101327] ICE in find_array_element, at fortran/expr.c:1355
  2021-07-05 16:38 [Bug fortran/101327] New: ICE in find_array_element, at fortran/expr.c:1355 gscfq@t-online.de
                   ` (5 preceding siblings ...)
  2021-09-07 18:52 ` cvs-commit at gcc dot gnu.org
@ 2021-09-11 19:01 ` cvs-commit at gcc dot gnu.org
  2021-09-16 18:33 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-09-11 19:01 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101327

--- 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:0d09acc0d627dcc7b3d82d873ee9da2f7546414e

commit r11-8979-g0d09acc0d627dcc7b3d82d873ee9da2f7546414e
Author: Harald Anlauf <anlauf@gmx.de>
Date:   Tue Sep 7 20:51:49 2021 +0200

    Fortran - improve error recovery determining array element from constructor

    gcc/fortran/ChangeLog:

            PR fortran/101327
            * expr.c (find_array_element): When bounds cannot be determined as
            constant, return error instead of aborting.

    gcc/testsuite/ChangeLog:

            PR fortran/101327
            * gfortran.dg/pr101327.f90: New test.

    (cherry picked from commit 2a1537a19cb2fa85823cfa18ed40baa4b259b4e3)

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug fortran/101327] ICE in find_array_element, at fortran/expr.c:1355
  2021-07-05 16:38 [Bug fortran/101327] New: ICE in find_array_element, at fortran/expr.c:1355 gscfq@t-online.de
                   ` (6 preceding siblings ...)
  2021-09-11 19:01 ` cvs-commit at gcc dot gnu.org
@ 2021-09-16 18:33 ` cvs-commit at gcc dot gnu.org
  2021-09-30 19:28 ` cvs-commit at gcc dot gnu.org
  2021-09-30 19:30 ` anlauf at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-09-16 18:33 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101327

--- 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:5595cc9eb709c4aef1c7bbbfc6b106cf6d5bee91

commit r10-10132-g5595cc9eb709c4aef1c7bbbfc6b106cf6d5bee91
Author: Harald Anlauf <anlauf@gmx.de>
Date:   Tue Sep 7 20:51:49 2021 +0200

    Fortran - improve error recovery determining array element from constructor

    gcc/fortran/ChangeLog:

            PR fortran/101327
            * expr.c (find_array_element): When bounds cannot be determined as
            constant, return error instead of aborting.

    gcc/testsuite/ChangeLog:

            PR fortran/101327
            * gfortran.dg/pr101327.f90: New test.

    (cherry picked from commit 2a1537a19cb2fa85823cfa18ed40baa4b259b4e3)

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug fortran/101327] ICE in find_array_element, at fortran/expr.c:1355
  2021-07-05 16:38 [Bug fortran/101327] New: ICE in find_array_element, at fortran/expr.c:1355 gscfq@t-online.de
                   ` (7 preceding siblings ...)
  2021-09-16 18:33 ` cvs-commit at gcc dot gnu.org
@ 2021-09-30 19:28 ` cvs-commit at gcc dot gnu.org
  2021-09-30 19:30 ` anlauf at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-09-30 19:28 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101327

--- Comment #9 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-9 branch has been updated by Harald Anlauf
<anlauf@gcc.gnu.org>:

https://gcc.gnu.org/g:e3ad4c45d128c1f4a69f86116a36312aa593554c

commit r9-9751-ge3ad4c45d128c1f4a69f86116a36312aa593554c
Author: Harald Anlauf <anlauf@gmx.de>
Date:   Tue Sep 7 20:51:49 2021 +0200

    Fortran - improve error recovery determining array element from constructor

    gcc/fortran/ChangeLog:

            PR fortran/101327
            * expr.c (find_array_element): When bounds cannot be determined as
            constant, return error instead of aborting.

    gcc/testsuite/ChangeLog:

            PR fortran/101327
            * gfortran.dg/pr101327.f90: New test.

    (cherry picked from commit 2a1537a19cb2fa85823cfa18ed40baa4b259b4e3)

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug fortran/101327] ICE in find_array_element, at fortran/expr.c:1355
  2021-07-05 16:38 [Bug fortran/101327] New: ICE in find_array_element, at fortran/expr.c:1355 gscfq@t-online.de
                   ` (8 preceding siblings ...)
  2021-09-30 19:28 ` cvs-commit at gcc dot gnu.org
@ 2021-09-30 19:30 ` anlauf at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: anlauf at gcc dot gnu.org @ 2021-09-30 19:30 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101327

anlauf at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
   Target Milestone|---                         |9.5
             Status|NEW                         |RESOLVED

--- Comment #10 from anlauf at gcc dot gnu.org ---
Fixed on all open branches.  Closing.

Thanks for the report!

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2021-09-30 19:30 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-05 16:38 [Bug fortran/101327] New: ICE in find_array_element, at fortran/expr.c:1355 gscfq@t-online.de
2021-07-06 17:50 ` [Bug fortran/101327] " kargl at gcc dot gnu.org
2021-08-30 19:35 ` anlauf at gcc dot gnu.org
2021-08-30 20:02 ` sgk at troutmask dot apl.washington.edu
2021-08-30 20:13 ` anlauf at gcc dot gnu.org
2021-08-30 21:41 ` anlauf at gcc dot gnu.org
2021-09-07 18:52 ` cvs-commit at gcc dot gnu.org
2021-09-11 19:01 ` cvs-commit at gcc dot gnu.org
2021-09-16 18:33 ` cvs-commit at gcc dot gnu.org
2021-09-30 19:28 ` cvs-commit at gcc dot gnu.org
2021-09-30 19:30 ` anlauf 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).