------- Comment #14 from rguenth at gcc dot gnu dot org 2008-01-06 11:46 ------- As of optimization, the conversion sequence
atmp.0.data = &A.1; D.540_5 = atmp.0.data; D.541_6 = (real(kind=4)[0:] *) D.540_5; ... (*D.541_6)[S.5_1] = D.545_14; can be optimized to A.1[S.5_1] = D.545_14; with the following patch that makes sure we use (real(kind=4)[4] *) instead of the unknown size array type. Index: trans-types.c =================================================================== --- trans-types.c (revision 131336) +++ trans-types.c (working copy) @@ -1511,10 +1511,12 @@ gfc_get_array_type_bounds (tree etype, i /* TODO: known offsets for descriptors. */ GFC_TYPE_ARRAY_OFFSET (fat_type) = NULL_TREE; - /* We define data as an unknown size array. Much better than doing + /* We define data as an array with the correct size. Much better than doing pointer arithmetic. */ arraytype = - build_array_type (etype, gfc_array_range_type); + build_array_type (etype, build_range_type (gfc_array_index_type, + gfc_index_zero_node, int_const_binop (MINUS_EXPR, stride, + integer_one_node, 0))); arraytype = build_pointer_type (arraytype); GFC_TYPE_ARRAY_DATAPTR_TYPE (fat_type) = arraytype; (the patch needs to be adjusted for the cases stride is not the actual array size, but you should get the idea) -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34683