https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86065
kargl at gcc dot gnu.org changed: What |Removed |Added ---------------------------------------------------------------------------- Priority|P3 |P4 Status|UNCONFIRMED |WAITING Last reconfirmed| |2018-06-06 CC| |kargl at gcc dot gnu.org Ever confirmed|0 |1 --- Comment #1 from kargl at gcc dot gnu.org --- It appears that you need to update to a newer version of gfortran. The code gives the expected with 6.4.1, 7.3.1, 8.1.1, and 9.0.0. The 5-branch is closed to changes, so it will not be fixed in that branch.