https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98904
--- Comment #12 from David Binderman <dcb314 at hotmail dot com> --- (In reply to Tobias Burnus from comment #11) > It might be that some code optimizes converts ... > It might be that the either the middle end of GCC does this optimization or > that valgrind does this internally. I don't understand very much of your reply, but if you can replace your two mights with facts, that would be IMHO a step in the right direction. I replaced my existing fprintf code with slightly better code on the obvious conditional: if (flag_coarray == GFC_FCOARRAY_LIB) { fprintf( stderr, "flag_coarray %d\n", flag_coarray); fprintf( stderr, "lhs_caf_attr.codimension %d\n", lhs_caf_attr.codimension); fprintf( stderr, "rhs_caf_attr.codimension %d\n", rhs_caf_attr.codimension); fprintf( stderr, "lhs_caf_attr.allocatable %d\n", lhs_caf_attr.allocatable); fprintf( stderr, "lhs_refs_comp %d\n", lhs_refs_comp); fprintf( stderr, "rhs_caf_attr.allocatable %d\n", rhs_caf_attr.allocatable); fprintf( stderr, "rhs_refs_comp %d\n", rhs_refs_comp); } and, surprisingly, the problem seems to have gone away. Mind you, I did compile with -O2 this time, not -O3 as originally specified, so it looks like I get dodgy results if I build the fortran compiler with -O3. I will avoid this in future. Deeper minds might want to look into this problem some more.