------- Comment #3 from burnus at gcc dot gnu dot org 2010-04-29 14:34 ------- The issue is that a.dim[] is too small, which was traced by Alexander Monakov (thanks!).
This is in turn due to: gfc_get_array_descriptor_base (int dimen, int codimen, bool restricted) { int idx = 2 * (dimen - 1) + restricted; [...] gfc_array_descriptor_base[idx] = fat_type; Possible patch (untested) below. However, as coarrays do not need to agree on the coranks (except for allocatable ones), coarrays with different corank are compatible. Ditto for passing a coarray to a non-coarray. Thus, the patch below will cause problems for integer :: coarray(1)[2,*] call foo(coarray) to subroutine foo(coarray) integer :: coarray(1)[*] or to subroutine foo(array) integer :: array(1) as the coranks don't agree and thus not the type. I have to think about how to solve this best. For allocatable coarrays there is no problem, as there the coranks have to agree. Index: trans-types.c =================================================================== --- trans-types.c (revision 158895) +++ trans-types.c (working copy) @@ -1542,7 +1542,7 @@ { tree fat_type, fieldlist, decl, arraytype; char name[16 + 2*GFC_RANK_DIGITS + 1 + 1]; - int idx = 2 * (dimen - 1) + restricted; + int idx = 2 * (codimen + dimen - 1) + restricted; gcc_assert (dimen >= 1 && codimen + dimen <= GFC_MAX_DIMENSIONS); if (gfc_array_descriptor_base[idx]) @@ -1551,8 +1551,7 @@ /* Build the type node. */ fat_type = make_node (RECORD_TYPE); - sprintf (name, "array_descriptor" GFC_RANK_PRINTF_FORMAT "_" - GFC_RANK_PRINTF_FORMAT, dimen, codimen); + sprintf (name, "array_descriptor" GFC_RANK_PRINTF_FORMAT, dimen + codimen); TYPE_NAME (fat_type) = get_identifier (name); /* Add the data member as the first element of the descriptor. */ @@ -1629,8 +1628,7 @@ type_name = IDENTIFIER_POINTER (tmp); else type_name = "unknown"; - sprintf (name, "array" GFC_RANK_PRINTF_FORMAT "_" - GFC_RANK_PRINTF_FORMAT "_%.*s", dimen, codimen, + sprintf (name, "array" GFC_RANK_PRINTF_FORMAT "_%.*s", dimen + codimen, GFC_MAX_SYMBOL_LEN, type_name); TYPE_NAME (fat_type) = get_identifier (name); -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43931