------- Comment #3 from fxcoudert at gcc dot gnu dot org 2008-05-18 14:55 ------- I have some more information, but it still doesn't make sense. I'm comparing the codepaths taken in the front-end by:
implicit none character(len=5), dimension(3,3), parameter :: & p = reshape(["a", "b", "c", "d", "e", "f", "g", "h", "i"], [3,3]) character(len=5), dimension(3,3) :: m1 m1 = p print '(18A)', spread (m1, 1, 2)//"z" end and: implicit none character(len=5), dimension(3,3), parameter :: & p = reshape(["a", "b", "c", "d", "e", "f", "g", "h", "i"], [3,3]) print '(18A)', spread (p, 1, 2)//"z" end In both cases, we end up twice in gfc_resolve_spread, but while for a non-parameter array, we always give the return type its correct rank (f->rank = 3), for the paramater array, we give it a rank of 2 the second time. That's because in check_charlen_present(), the source->rank gets modified from 2 to 1). I don't understand why we do this (someone assumed that we can only have array parameters with rank 1?) So, commenting that piece of code there: Index: iresolve.c =================================================================== --- iresolve.c (revision 135395) +++ iresolve.c (working copy) @@ -78,7 +78,7 @@ check_charlen_present (gfc_expr *source) { source->ts.cl->length = gfc_int_expr (source->value.constructor->expr->value.character.length); - source->rank = 1; + /*source->rank = 1;*/ } } make that testcase work, but I wonder what else it breaks :) -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36257