http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57906
Bug ID: 57906 Summary: Coarray components: Assignment optimized away (gfortran.dg/coarray/lib_realloc_1.f90) Product: gcc Version: 4.9.0 Status: UNCONFIRMED Keywords: wrong-code Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: burnus at gcc dot gnu.org gfortran.dg/coarray/lib_realloc_1.f90 (r200955) fails if compiled with optimization. It has: type t integer, allocatable :: CAF[:] end type t ... x = y which gives with -O0 the dump: D.1903 = x; x = y; x.caf = D.1903.caf; Namely: The fields of the struct "x" are updated from "y" - but the "caf" field is re-set to the previous value of x. (Reason: The x.caf.data is a pointer, whose previous address has to be kept. That's a special feature of coarray components.) With optimization, the "x.caf = D.1903.caf" line is effectively lost - such that x.caf.data and y.caf.data point to the same memory.