public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/102619] New: [10/11/12 Regression] ICE in gfc_conv_descriptor_dtype, at fortran/trans-array.c:215
@ 2021-10-05 18:32 gscfq@t-online.de
  2021-10-05 18:33 ` [Bug fortran/102619] " gscfq@t-online.de
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: gscfq@t-online.de @ 2021-10-05 18:32 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 102619
           Summary: [10/11/12 Regression] ICE in
                    gfc_conv_descriptor_dtype, at
                    fortran/trans-array.c:215
           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: ---

Started with r9, changed between 20190310 and 20190331 :


$ cat z1.f90
program p
contains
   function f(x) result(z)
      real :: x(:)
      real, allocatable :: z(:)
      z = g(x)
   end
   function g(x)
      real :: x(..)
      real :: g(product(shape(x)))
   end
end


$ gfortran-9-20190310 -c z1.f90
$
$ gfortran-12-20211003 -c z1.f90
z1.f90:6:14:

    6 |       z = g(x)
      |              1
internal compiler error: in gfc_get_descriptor_field, at
fortran/trans-array.c:140
0x84b7e0 gfc_get_descriptor_field
        ../../gcc/fortran/trans-array.c:140
0x84ca2f gfc_conv_descriptor_dtype(tree_node*)
        ../../gcc/fortran/trans-array.c:215
0x84cab5 gfc_conv_descriptor_rank(tree_node*)
        ../../gcc/fortran/trans-array.c:249
0x8a3ac1 gfc_conv_intrinsic_shape
        ../../gcc/fortran/trans-intrinsic.c:6742
0x8a3ac1 gfc_conv_intrinsic_function(gfc_se*, gfc_expr*)
        ../../gcc/fortran/trans-intrinsic.c:10182
0x87956a gfc_conv_expr(gfc_se*, gfc_expr*)
        ../../gcc/fortran/trans-expr.c:9066
0x858440 gfc_add_loop_ss_code
        ../../gcc/fortran/trans-array.c:3029
0x858ff5 gfc_conv_loop_setup(gfc_loopinfo*, locus*)
        ../../gcc/fortran/trans-array.c:5293
0x89cae0 gfc_conv_intrinsic_arith
        ../../gcc/fortran/trans-intrinsic.c:4931
0x8a4cc4 gfc_conv_intrinsic_function(gfc_se*, gfc_expr*)
        ../../gcc/fortran/trans-intrinsic.c:10694
0x87956a gfc_conv_expr(gfc_se*, gfc_expr*)
        ../../gcc/fortran/trans-expr.c:9066
0x87ba1a gfc_apply_interface_mapping(gfc_interface_mapping*, gfc_se*,
gfc_expr*)
        ../../gcc/fortran/trans-expr.c:4874
0x84da17 gfc_set_loop_bounds_from_array_spec(gfc_interface_mapping*, gfc_se*,
gfc_array_spec*)
        ../../gcc/fortran/trans-array.c:949
0x886056 gfc_conv_procedure_call(gfc_se*, gfc_symbol*, gfc_actual_arglist*,
gfc_expr*, vec<tree_node*, va_gc, vl_embed>*)
        ../../gcc/fortran/trans-expr.c:7140
0x8876dc gfc_trans_arrayfunc_assign
        ../../gcc/fortran/trans-expr.c:10541
0x88b3b4 gfc_trans_assignment(gfc_expr*, gfc_expr*, bool, bool, bool, bool)
        ../../gcc/fortran/trans-expr.c:11710
0x84ac37 trans_code
        ../../gcc/fortran/trans.c:1918
0x871974 gfc_generate_function_code(gfc_namespace*)
        ../../gcc/fortran/trans-decl.c:6905
0x871774 gfc_generate_contained_functions
        ../../gcc/fortran/trans-decl.c:5899
0x871774 gfc_generate_function_code(gfc_namespace*)
        ../../gcc/fortran/trans-decl.c:6837

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

* [Bug fortran/102619] [10/11/12 Regression] ICE in gfc_conv_descriptor_dtype, at fortran/trans-array.c:215
  2021-10-05 18:32 [Bug fortran/102619] New: [10/11/12 Regression] ICE in gfc_conv_descriptor_dtype, at fortran/trans-array.c:215 gscfq@t-online.de
@ 2021-10-05 18:33 ` gscfq@t-online.de
  2021-10-06  8:40 ` rguenth at gcc dot gnu.org
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: gscfq@t-online.de @ 2021-10-05 18:33 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

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

While synonym z0.f90 compiles, the other variants don't :


$ cat z0.f90
program p
contains
   function f(x) result(z)
      real :: x(:)
      real, allocatable :: z(:)
      z = g(x)
   end
   function g(x)
      real :: x(..)
      real :: g(size(x))
   end
end


$ cat z2.f90
program p
contains
   function f(x) result(z)
      real :: x(:)
      real, allocatable :: z(:)
      z = g(x)
   end
   function g(x)
      real :: x(..)
      real :: g(product(ubound(x)-lbound(x)+1))
   end
end


$ cat z3.f90
program p
contains
   function f(x) result(z)
      real :: x(:)
      real, allocatable :: z(:)
      z = g(x)
   end
   function g(x)
      real :: x(..)
      real :: g(product(ubound(x)))
   end
end

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

* [Bug fortran/102619] [10/11/12 Regression] ICE in gfc_conv_descriptor_dtype, at fortran/trans-array.c:215
  2021-10-05 18:32 [Bug fortran/102619] New: [10/11/12 Regression] ICE in gfc_conv_descriptor_dtype, at fortran/trans-array.c:215 gscfq@t-online.de
  2021-10-05 18:33 ` [Bug fortran/102619] " gscfq@t-online.de
@ 2021-10-06  8:40 ` rguenth at gcc dot gnu.org
  2021-10-11  8:24 ` [Bug fortran/102619] [10/11/12 Regression] ICE in gfc_conv_descriptor_dtype, at fortran/trans-array.c:215 since r9-6493-g0e3088806577e805 marxin at gcc dot gnu.org
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-10-06  8:40 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P4
   Target Milestone|---                         |10.4

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

* [Bug fortran/102619] [10/11/12 Regression] ICE in gfc_conv_descriptor_dtype, at fortran/trans-array.c:215 since r9-6493-g0e3088806577e805
  2021-10-05 18:32 [Bug fortran/102619] New: [10/11/12 Regression] ICE in gfc_conv_descriptor_dtype, at fortran/trans-array.c:215 gscfq@t-online.de
  2021-10-05 18:33 ` [Bug fortran/102619] " gscfq@t-online.de
  2021-10-06  8:40 ` rguenth at gcc dot gnu.org
@ 2021-10-11  8:24 ` marxin at gcc dot gnu.org
  2022-06-28 10:46 ` [Bug fortran/102619] [10/11/12/13 " jakub at gcc dot gnu.org
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: marxin at gcc dot gnu.org @ 2021-10-11  8:24 UTC (permalink / raw)
  To: gcc-bugs

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

Martin Liška <marxin at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
            Summary|[10/11/12 Regression] ICE   |[10/11/12 Regression] ICE
                   |in                          |in
                   |gfc_conv_descriptor_dtype,  |gfc_conv_descriptor_dtype,
                   |at                          |at
                   |fortran/trans-array.c:215   |fortran/trans-array.c:215
                   |                            |since
                   |                            |r9-6493-g0e3088806577e805
   Last reconfirmed|                            |2021-10-11
                 CC|                            |marxin at gcc dot gnu.org
             Status|UNCONFIRMED                 |NEW

--- Comment #2 from Martin Liška <marxin at gcc dot gnu.org> ---
Started likely with r9-6493-g0e3088806577e805.

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

* [Bug fortran/102619] [10/11/12/13 Regression] ICE in gfc_conv_descriptor_dtype, at fortran/trans-array.c:215 since r9-6493-g0e3088806577e805
  2021-10-05 18:32 [Bug fortran/102619] New: [10/11/12 Regression] ICE in gfc_conv_descriptor_dtype, at fortran/trans-array.c:215 gscfq@t-online.de
                   ` (2 preceding siblings ...)
  2021-10-11  8:24 ` [Bug fortran/102619] [10/11/12 Regression] ICE in gfc_conv_descriptor_dtype, at fortran/trans-array.c:215 since r9-6493-g0e3088806577e805 marxin at gcc dot gnu.org
@ 2022-06-28 10:46 ` jakub at gcc dot gnu.org
  2023-07-07 10:41 ` [Bug fortran/102619] [11/12/13/14 " rguenth at gcc dot gnu.org
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: jakub at gcc dot gnu.org @ 2022-06-28 10:46 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|10.4                        |10.5

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
GCC 10.4 is being released, retargeting bugs to GCC 10.5.

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

* [Bug fortran/102619] [11/12/13/14 Regression] ICE in gfc_conv_descriptor_dtype, at fortran/trans-array.c:215 since r9-6493-g0e3088806577e805
  2021-10-05 18:32 [Bug fortran/102619] New: [10/11/12 Regression] ICE in gfc_conv_descriptor_dtype, at fortran/trans-array.c:215 gscfq@t-online.de
                   ` (3 preceding siblings ...)
  2022-06-28 10:46 ` [Bug fortran/102619] [10/11/12/13 " jakub at gcc dot gnu.org
@ 2023-07-07 10:41 ` rguenth at gcc dot gnu.org
  2024-05-27 20:11 ` [Bug fortran/102619] [11/12/13/14/15 " anlauf at gcc dot gnu.org
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-07-07 10:41 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|10.5                        |11.5

--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 10 branch is being closed.

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

* [Bug fortran/102619] [11/12/13/14/15 Regression] ICE in gfc_conv_descriptor_dtype, at fortran/trans-array.c:215 since r9-6493-g0e3088806577e805
  2021-10-05 18:32 [Bug fortran/102619] New: [10/11/12 Regression] ICE in gfc_conv_descriptor_dtype, at fortran/trans-array.c:215 gscfq@t-online.de
                   ` (4 preceding siblings ...)
  2023-07-07 10:41 ` [Bug fortran/102619] [11/12/13/14 " rguenth at gcc dot gnu.org
@ 2024-05-27 20:11 ` anlauf at gcc dot gnu.org
  2024-05-28 19:20 ` anlauf at gcc dot gnu.org
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: anlauf at gcc dot gnu.org @ 2024-05-27 20:11 UTC (permalink / raw)
  To: gcc-bugs

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

anlauf at gcc dot gnu.org changed:

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

--- Comment #5 from anlauf at gcc dot gnu.org ---
The ICE occurs for both SUM and PRODUCT of SHAPE,LBOUND,UBOUND of the
assumed-rank dummy.

The ICE points to gfc_conv_intrinsic_arith:

4929          gfc_conv_ss_startstride (&loop);

The difference between assumed-shape vs. assumed-rank argument is:

(gdb) p *loop->ss->info->expr->shape->_mp_d
$86 = 1

vs.

(gdb) p loop->ss->info->expr->shape
$88 = (mpz_t *) 0x0

Now gfc_conv_ss_startstride should be able to handle assumed-rank,
but then we die here:

(gdb) l 4811,4826
4811                    arg = expr->value.function.actual->expr;
4812                    if (arg->rank == -1)
4813                      {
4814                        gfc_se se;
4815                        tree rank, tmp;
4816
4817                        /* The rank (hence the return value's shape) is
unknown,
4818                           we have to retrieve it.  */
4819                        gfc_init_se (&se, NULL);
4820                        se.descriptor_only = 1;
4821                        gfc_conv_expr (&se, arg);
4822                        /* This is a bare variable, so there is no
preliminary
4823                           or cleanup code.  */
4824                        gcc_assert (se.pre.head == NULL_TREE
4825                                    && se.post.head == NULL_TREE);
4826                        rank = gfc_conv_descriptor_rank (se.expr);

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

* [Bug fortran/102619] [11/12/13/14/15 Regression] ICE in gfc_conv_descriptor_dtype, at fortran/trans-array.c:215 since r9-6493-g0e3088806577e805
  2021-10-05 18:32 [Bug fortran/102619] New: [10/11/12 Regression] ICE in gfc_conv_descriptor_dtype, at fortran/trans-array.c:215 gscfq@t-online.de
                   ` (5 preceding siblings ...)
  2024-05-27 20:11 ` [Bug fortran/102619] [11/12/13/14/15 " anlauf at gcc dot gnu.org
@ 2024-05-28 19:20 ` anlauf at gcc dot gnu.org
  2024-05-29  1:06 ` jvdelisle2 at gmail dot com
  2024-05-29 18:07 ` mikael at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: anlauf at gcc dot gnu.org @ 2024-05-28 19:20 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from anlauf at gcc dot gnu.org ---
Created attachment 58302
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=58302&action=edit
Partial patch

This change prevents the ICE and leads to a correct shape of the function
result for the following testcase:

program p
  implicit none
  real :: w(2,3)
  real, allocatable :: y(:)
  y = h(w)
  print *, size (y) ! Should print 6
  print *, y
  deallocate (y)
contains
  function h(x) result (g)
    real :: x(..)
    real :: g(product(shape(x)))
    integer :: i
    print *, shape (x)
    print *, size (g)
    g = [(real(i),i=1,size(g))]
    print *, g
  end
end

After the patch this prints:

           2           3
           6
   1.00000000       2.00000000       3.00000000       4.00000000      
5.00000000       6.00000000    
           1
   1.00000000    

So the function result is not allocated correctly.

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

* [Bug fortran/102619] [11/12/13/14/15 Regression] ICE in gfc_conv_descriptor_dtype, at fortran/trans-array.c:215 since r9-6493-g0e3088806577e805
  2021-10-05 18:32 [Bug fortran/102619] New: [10/11/12 Regression] ICE in gfc_conv_descriptor_dtype, at fortran/trans-array.c:215 gscfq@t-online.de
                   ` (6 preceding siblings ...)
  2024-05-28 19:20 ` anlauf at gcc dot gnu.org
@ 2024-05-29  1:06 ` jvdelisle2 at gmail dot com
  2024-05-29 18:07 ` mikael at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: jvdelisle2 at gmail dot com @ 2024-05-29  1:06 UTC (permalink / raw)
  To: gcc-bugs

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

Jerry DeLisle <jvdelisle2 at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jvdelisle2 at gmail dot com

--- Comment #7 from Jerry DeLisle <jvdelisle2 at gmail dot com> ---
Interestingly, real :: x(:,:) works vs real :: x(..) in the function
declaration with your partial patch.

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

* [Bug fortran/102619] [11/12/13/14/15 Regression] ICE in gfc_conv_descriptor_dtype, at fortran/trans-array.c:215 since r9-6493-g0e3088806577e805
  2021-10-05 18:32 [Bug fortran/102619] New: [10/11/12 Regression] ICE in gfc_conv_descriptor_dtype, at fortran/trans-array.c:215 gscfq@t-online.de
                   ` (7 preceding siblings ...)
  2024-05-29  1:06 ` jvdelisle2 at gmail dot com
@ 2024-05-29 18:07 ` mikael at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: mikael at gcc dot gnu.org @ 2024-05-29 18:07 UTC (permalink / raw)
  To: gcc-bugs

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

Mikael Morin <mikael at gcc dot gnu.org> changed:

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

--- Comment #8 from Mikael Morin <mikael at gcc dot gnu.org> ---
The reason why the variable is not represented with an array descriptor is the
interface mapping mechanism to evaluate dummy array bounds.
gfc_add_interface_mapping replaces the normal variable decl with a
descriptorless (GFC_ARRAY_TYPE_P == 1) array.  The rank for those is
GFC_TYPE_ARRAY_RANK, which is #defined to (TYPE_LANG_SPECIFIC(node)->rank).
And lang_type declares the rank field with:
  int rank, corank;
so compile-time only rank.
gfc_set_interface_mapping_bounds uses a loop bounded by GFC_TYPE_ARRAY_RANK, so
it does nothing if the rank is -1 as with assumed rank.

So we expect a regular array descriptor from which we can get the runtime rank,
and we get a descriptorless array of rank -1 with unset bounds.
No wonder it doesn't work.

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

end of thread, other threads:[~2024-05-29 18:07 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-05 18:32 [Bug fortran/102619] New: [10/11/12 Regression] ICE in gfc_conv_descriptor_dtype, at fortran/trans-array.c:215 gscfq@t-online.de
2021-10-05 18:33 ` [Bug fortran/102619] " gscfq@t-online.de
2021-10-06  8:40 ` rguenth at gcc dot gnu.org
2021-10-11  8:24 ` [Bug fortran/102619] [10/11/12 Regression] ICE in gfc_conv_descriptor_dtype, at fortran/trans-array.c:215 since r9-6493-g0e3088806577e805 marxin at gcc dot gnu.org
2022-06-28 10:46 ` [Bug fortran/102619] [10/11/12/13 " jakub at gcc dot gnu.org
2023-07-07 10:41 ` [Bug fortran/102619] [11/12/13/14 " rguenth at gcc dot gnu.org
2024-05-27 20:11 ` [Bug fortran/102619] [11/12/13/14/15 " anlauf at gcc dot gnu.org
2024-05-28 19:20 ` anlauf at gcc dot gnu.org
2024-05-29  1:06 ` jvdelisle2 at gmail dot com
2024-05-29 18:07 ` mikael 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).