public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/105184] New: ICE in gfc_array_init_size, at fortran/trans-array.cc:5841
@ 2022-04-06 18:20 gscfq@t-online.de
  2022-04-06 18:21 ` [Bug fortran/105184] " gscfq@t-online.de
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: gscfq@t-online.de @ 2022-04-06 18:20 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 105184
           Summary: ICE in gfc_array_init_size, at
                    fortran/trans-array.cc:5841
           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
program p
   real, allocatable :: x[:,:]
   integer :: n = 2
   allocate (x[::n, *])
end


$ gfortran-12-20220403 -c z1.f90 -fcoarray=single
z1.f90:4:23:

    4 |    allocate (x[::n, *])
      |                       1
internal compiler error: in gfc_array_init_size, at fortran/trans-array.cc:5841
0x7b4647 gfc_array_init_size
        ../../gcc/fortran/trans-array.cc:5841
0x7b4647 gfc_array_allocate(gfc_se*, gfc_expr*, tree_node*, tree_node*,
tree_node*, tree_node*, tree_node*, tree_node**, gfc_expr*, tree_node*, bool)
        ../../gcc/fortran/trans-array.cc:6119
0x829de6 gfc_trans_allocate(gfc_code*)
        ../../gcc/fortran/trans-stmt.cc:6741
0x7ab8c7 trans_code
        ../../gcc/fortran/trans.cc:2088
0x7d4b7e gfc_generate_function_code(gfc_namespace*)
        ../../gcc/fortran/trans-decl.cc:7654
0x75734e translate_all_program_units
        ../../gcc/fortran/parse.cc:6669
0x75734e gfc_parse_file()
        ../../gcc/fortran/parse.cc:6956
0x7a47df gfc_be_parse_file
        ../../gcc/fortran/f95-lang.cc:216

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

* [Bug fortran/105184] ICE in gfc_array_init_size, at fortran/trans-array.cc:5841
  2022-04-06 18:20 [Bug fortran/105184] New: ICE in gfc_array_init_size, at fortran/trans-array.cc:5841 gscfq@t-online.de
@ 2022-04-06 18:21 ` gscfq@t-online.de
  2022-04-06 19:09 ` anlauf at gcc dot gnu.org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: gscfq@t-online.de @ 2022-04-06 18:21 UTC (permalink / raw)
  To: gcc-bugs

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

G. Steinmetz <gscfq@t-online.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |ice-on-invalid-code

--- Comment #1 from G. Steinmetz <gscfq@t-online.de> ---


Error detected with a constant instead :


$ cat z2.f90
program p
   real, allocatable :: x[:,:]
   integer, parameter :: n = 2
   allocate (x[::n, *])
end


$ cat z3.f90
program p
   real, allocatable :: x[:,:]
   allocate (x[::2, *])
end


$ gfortran-12-20220403 -c z2.f90 -fcoarray=single
z2.f90:4:15:

    4 |    allocate (x[::n, *])
      |               1
Error: Bad array dimension at (1)

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

* [Bug fortran/105184] ICE in gfc_array_init_size, at fortran/trans-array.cc:5841
  2022-04-06 18:20 [Bug fortran/105184] New: ICE in gfc_array_init_size, at fortran/trans-array.cc:5841 gscfq@t-online.de
  2022-04-06 18:21 ` [Bug fortran/105184] " gscfq@t-online.de
@ 2022-04-06 19:09 ` anlauf at gcc dot gnu.org
  2022-04-06 20:03 ` anlauf at gcc dot gnu.org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: anlauf at gcc dot gnu.org @ 2022-04-06 19:09 UTC (permalink / raw)
  To: gcc-bugs

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

anlauf at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2022-04-06

--- Comment #2 from anlauf at gcc dot gnu.org ---
Confirmed.

The checking for bad array shape specifications needs improvement.

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

* [Bug fortran/105184] ICE in gfc_array_init_size, at fortran/trans-array.cc:5841
  2022-04-06 18:20 [Bug fortran/105184] New: ICE in gfc_array_init_size, at fortran/trans-array.cc:5841 gscfq@t-online.de
  2022-04-06 18:21 ` [Bug fortran/105184] " gscfq@t-online.de
  2022-04-06 19:09 ` anlauf at gcc dot gnu.org
@ 2022-04-06 20:03 ` anlauf at gcc dot gnu.org
  2022-04-06 20:40 ` anlauf at gcc dot gnu.org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: anlauf at gcc dot gnu.org @ 2022-04-06 20:03 UTC (permalink / raw)
  To: gcc-bugs

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

anlauf at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |anlauf at gcc dot gnu.org

--- Comment #3 from anlauf at gcc dot gnu.org ---
Testing the following patch:

diff --git a/gcc/fortran/resolve.cc b/gcc/fortran/resolve.cc
index 21c8797c938..45a04dab703 100644
--- a/gcc/fortran/resolve.cc
+++ b/gcc/fortran/resolve.cc
@@ -8108,12 +8108,12 @@ resolve_allocate_expr (gfc_expr *e, gfc_code *code,
bool *array_alloc_wo_spec)
            goto failure;

          case  DIMEN_RANGE:
-           if (ar->start[i] == 0 || ar->end[i] == 0)
+           // F2018:R937:
+           // allocate-coshape-spec is [ lower-bound-expr : ] upper-bound-expr
+           if (ar->start[i] == 0 || ar->end[i] == 0 || ar->stride[i] != NULL)
              {
-               /* If ar->stride[i] is NULL, we issued a previous error.  */
-               if (ar->stride[i] == NULL)
-                 gfc_error ("Bad array specification in ALLOCATE statement "
-                            "at %L", &e->where);
+               gfc_error ("Bad array specification in ALLOCATE statement "
+                          "at %L", &e->where);
                goto failure;
              }
            else if (gfc_dep_compare_expr (ar->start[i], ar->end[i]) == 1)

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

* [Bug fortran/105184] ICE in gfc_array_init_size, at fortran/trans-array.cc:5841
  2022-04-06 18:20 [Bug fortran/105184] New: ICE in gfc_array_init_size, at fortran/trans-array.cc:5841 gscfq@t-online.de
                   ` (2 preceding siblings ...)
  2022-04-06 20:03 ` anlauf at gcc dot gnu.org
@ 2022-04-06 20:40 ` anlauf at gcc dot gnu.org
  2022-04-10 18:28 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: anlauf at gcc dot gnu.org @ 2022-04-06 20:40 UTC (permalink / raw)
  To: gcc-bugs

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

anlauf at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |anlauf at gcc dot gnu.org

--- Comment #4 from anlauf at gcc dot gnu.org ---
Submitted: https://gcc.gnu.org/pipermail/fortran/2022-April/057743.html

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

* [Bug fortran/105184] ICE in gfc_array_init_size, at fortran/trans-array.cc:5841
  2022-04-06 18:20 [Bug fortran/105184] New: ICE in gfc_array_init_size, at fortran/trans-array.cc:5841 gscfq@t-online.de
                   ` (3 preceding siblings ...)
  2022-04-06 20:40 ` anlauf at gcc dot gnu.org
@ 2022-04-10 18:28 ` cvs-commit at gcc dot gnu.org
  2022-04-10 18:34 ` anlauf at gcc dot gnu.org
  2022-04-12 17:23 ` gscfq@t-online.de
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-04-10 18:28 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 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:54c5e064cc3dc3c9b3dff12b6d48dc3efd482b07

commit r12-8073-g54c5e064cc3dc3c9b3dff12b6d48dc3efd482b07
Author: Harald Anlauf <anlauf@gmx.de>
Date:   Wed Apr 6 22:24:21 2022 +0200

    Fortran: fix checking of coshape specification in ALLOCATE statement

    gcc/fortran/ChangeLog:

            PR fortran/105184
            * array.cc (match_subscript): Reject assumed size coarray
            specification with missing lower bound.
            * resolve.cc (resolve_allocate_expr): Fix logic for checking
            allocate-coshape-spec in ALLOCATE statement.

    gcc/testsuite/ChangeLog:

            PR fortran/105184
            * gfortran.dg/coarray_44.f90: Adjust expected output.
            * gfortran.dg/coarray_allocate_11.f90: Likewise.
            * gfortran.dg/coarray_allocate_12.f90: New test.

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

* [Bug fortran/105184] ICE in gfc_array_init_size, at fortran/trans-array.cc:5841
  2022-04-06 18:20 [Bug fortran/105184] New: ICE in gfc_array_init_size, at fortran/trans-array.cc:5841 gscfq@t-online.de
                   ` (4 preceding siblings ...)
  2022-04-10 18:28 ` cvs-commit at gcc dot gnu.org
@ 2022-04-10 18:34 ` anlauf at gcc dot gnu.org
  2022-04-12 17:23 ` gscfq@t-online.de
  6 siblings, 0 replies; 8+ messages in thread
From: anlauf at gcc dot gnu.org @ 2022-04-10 18:34 UTC (permalink / raw)
  To: gcc-bugs

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

anlauf at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|ASSIGNED                    |RESOLVED
   Target Milestone|---                         |12.0

--- Comment #6 from anlauf at gcc dot gnu.org ---
Fixed for gcc-12.  Closing.

Thanks for the report!

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

* [Bug fortran/105184] ICE in gfc_array_init_size, at fortran/trans-array.cc:5841
  2022-04-06 18:20 [Bug fortran/105184] New: ICE in gfc_array_init_size, at fortran/trans-array.cc:5841 gscfq@t-online.de
                   ` (5 preceding siblings ...)
  2022-04-10 18:34 ` anlauf at gcc dot gnu.org
@ 2022-04-12 17:23 ` gscfq@t-online.de
  6 siblings, 0 replies; 8+ messages in thread
From: gscfq@t-online.de @ 2022-04-12 17:23 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from G. Steinmetz <gscfq@t-online.de> ---
Thank you very much for fixing this problem !

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

end of thread, other threads:[~2022-04-12 17:23 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-06 18:20 [Bug fortran/105184] New: ICE in gfc_array_init_size, at fortran/trans-array.cc:5841 gscfq@t-online.de
2022-04-06 18:21 ` [Bug fortran/105184] " gscfq@t-online.de
2022-04-06 19:09 ` anlauf at gcc dot gnu.org
2022-04-06 20:03 ` anlauf at gcc dot gnu.org
2022-04-06 20:40 ` anlauf at gcc dot gnu.org
2022-04-10 18:28 ` cvs-commit at gcc dot gnu.org
2022-04-10 18:34 ` anlauf at gcc dot gnu.org
2022-04-12 17:23 ` gscfq@t-online.de

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).