[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
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102619 Mikael Morin changed: What|Removed |Added CC||mikael at gcc dot gnu.org --- Comment #8 from Mikael Morin --- 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.
[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
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102619 Jerry DeLisle changed: What|Removed |Added CC||jvdelisle2 at gmail dot com --- Comment #7 from Jerry DeLisle --- Interestingly, real :: x(:,:) works vs real :: x(..) in the function declaration with your partial patch.
[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
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=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. 2. 3. 4. 5. 6. 1 1. So the function result is not allocated correctly.
[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
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 (); 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 4811arg = expr->value.function.actual->expr; 4812if (arg->rank == -1) 4813 { 4814gfc_se se; 4815tree rank, tmp; 4816 4817/* The rank (hence the return value's shape) is unknown, 4818 we have to retrieve it. */ 4819gfc_init_se (, NULL); 4820se.descriptor_only = 1; 4821gfc_conv_expr (, arg); 4822/* This is a bare variable, so there is no preliminary 4823 or cleanup code. */ 4824gcc_assert (se.pre.head == NULL_TREE 4825&& se.post.head == NULL_TREE); 4826rank = gfc_conv_descriptor_rank (se.expr);