https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98904

--- Comment #11 from Tobias Burnus <burnus at gcc dot gnu.org> ---
(In reply to David Binderman from comment #10)
> lhs_caf_attr.codimension is uninitialised.

It is clear that lhs_caf_attr is uninitialized
- if and only if flag_coarray != GFC_FCOARRAY_LIB

It might be that some code optimizes converts

  if (flag_coarray == GFC_FCOARRAY_LIB && lhs_caf_attr.codimension)

to

  if (flag_coarray == GFC_FCOARRAY_LIB & lhs_caf_attr.codimension)

to speed up – relying that lhs_caf_attr.codimension accesses valid memory
(which may be uninitialized). The replacement would work correctly anywhere
where accessing uninitialized memory works. As: if flag_coarray ==
GFC_FCOARRAY_LIB is 0, the value of lhs_caf_attr.codimension does not matter –
and if it is not 0, lhs_caf_attr.codimension is properly initialized.

It might be that the either the middle end of GCC does this optimization or
that valgrind does this internally.

In any case, the Fortran-compiler part is perfectly valid C/C++.

Reply via email to