http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60576

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
at's dim array is created by:
#6  0x00000000006fc242 in gfc_get_array_descriptor_base (dimen=2, codimen=0,
restricted=true, akind=GFC_ARRAY_ALLOCATABLE)
    at ../../gcc/fortran/trans-types.c:1754
where the dimen=2 causes the dim array to be sized with 2 elements only, while
the larger ARRAY_REF comes from:
#4  0x0000000000e58b85 in build4_stat (code=ARRAY_RANGE_REF, tt=<array_type
0x7ffff19f0540>, arg0=<component_ref 0x7ffff1a08510>, 
    arg1=<integer_cst 0x7ffff18afa00>, arg2=<tree 0x0>, arg3=<tree 0x0>) at
../../gcc/tree.c:4241
#5  0x00000000006a8a72 in build4_stat_loc (loc=2692, code=ARRAY_RANGE_REF,
type=<array_type 0x7ffff19f0540>, arg0=<component_ref 0x7ffff1a08510>, 
    arg1=<integer_cst 0x7ffff18afa00>, arg2=<tree 0x0>, arg3=<tree 0x0>) at
../../gcc/tree.h:3499
#6  0x00000000006a98ff in class_array_data_assign (block=0x7fffffffd810,
lhs_desc=<component_ref 0x7ffff1a08390>, 
    rhs_desc=<var_decl 0x7ffff1a052f8 at>, lhs_type=true) at
../../gcc/fortran/trans-expr.c:318
#7  0x00000000006a9ef5 in gfc_conv_derived_to_class (parmse=0x7fffffffd9a0,
e=0x1cd0640, class_ts=..., vptr=<tree 0x0>, optional=false, 
    optional_alloc_ptr=false) at ../../gcc/fortran/trans-expr.c:427
#8  0x00000000006b3d51 in gfc_conv_procedure_call (se=0x7fffffffdbe0,
sym=0x1ccc570, args=0x1c63760, expr=0x0, append_args=0x0)
    at ../../gcc/fortran/trans-expr.c:4039

The bug is in there already in r189800:
./f951.189800 -quiet -O2 assumed_rank_7.f90 -mstringop-strategy=libcall;
gfortran -o assumed_rank_7{,.s}; valgrind ./assumed_rank_7; echo $?
==7529== Memcheck, a memory error detector
==7529== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==7529== Using Valgrind-3.9.0 and LibVEX; rerun with -h for copyright info
==7529== Command: ./assumed_rank_7
==7529== 
==7529== Source and destination overlap in memcpy(0xfff0001b8, 0xfff000168,
168)
==7529==    at 0x4A0A403: memcpy@@GLIBC_2.14 (in
/usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==7529==    by 0x400F5B: MAIN__ (in /usr/src/gcc-test/obj/gcc/assumed_rank_7)
==7529==    by 0x4007AC: main (in /usr/src/gcc-test/obj/gcc/assumed_rank_7)
and r189600 still rejected this code, so to me this doesn't look like a
regression, but miscompilation from the day one when this particular feature
has been enabled.

Reply via email to