------- Comment #3 from fxcoudert at gcc dot gnu dot org 2006-05-28 13:23 ------- I tried with the following reduced testcase:
implicit none integer :: i logical :: l type dt integer, pointer :: a => null() end type dt type(dt), pointer :: obj(:) => null() allocate(obj(2)) i = 1 l = associated(obj(i)%a) print *, l end The code generated for the ASSOCIATED statement is the following when bounds-checking is disabled: i = 1; l = (*(struct dt[0:] *) obj.data)[obj.dim[0].stride * i + obj.offset].a != 0B; When bounds-checking is enabled, it is changed into: i = 1; { int4 D.924; l = (*(struct dt[0:] *) obj.data)[obj.dim[0].stride * D.924 + obj.offset].a != 0B; } Notice that D.924 is used uninitialized. The -fbounds-check options gives a special codepath in three occasions: 0x080ad083 in gfc_conv_ss_startstride (loop=0xbfa1813c) at ../../../trunk/gcc/fortran/trans-array.c:2456 2456 if (flag_bounds_check) (gdb) c Continuing. Hardware read watchpoint 1: flag_bounds_check Value = 1 0x080acc2c in gfc_conv_array_ref (se=0xbfa17ab4, ar=0x87222bc) at ../../../trunk/gcc/fortran/trans-array.c:1951 1951 if (flag_bounds_check && ar->as->type != AS_ASSUMED_SIZE) (gdb) Continuing. Hardware read watchpoint 1: flag_bounds_check Value = 1 0x080acd5c in gfc_conv_array_ref (se=0xbfa17ab4, ar=0x87222bc) at ../../../trunk/gcc/fortran/trans-array.c:1980 1980 if (flag_bounds_check) I don't understand where this D.924 variable is generated. -- fxcoudert at gcc dot gnu dot org changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |fxcoudert at gcc dot gnu dot | |org Last reconfirmed|2006-03-22 21:22:10 |2006-05-28 13:23:39 date| | http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26801