https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100989
Bug ID: 100989 Summary: Bogus internal VOLATILE attribute for ASYNCHRONOUS Product: gcc Version: 12.0 Status: UNCONFIRMED Keywords: missed-optimization Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: burnus at gcc dot gnu.org CC: tkoenig at gcc dot gnu.org Target Milestone: --- For a long time, there was the believe that due to GCC's pointer-escape semantic, which follows C, no special attribute is needed for asynchronous: ... integer, asynchronous :: A call init_action(A) ! pointer escape due to by-ref and GCC's C semantic ... ! and due to 'asynchronous' due to Fortran semantic A = 5 ! (probably a bad idea if really asynchronous) ... call wait() ! arrives here, can access A due to escaped pointer ! <-- value of 'A' could have changed There might be an issue with the handling of the 'fn attr', though as the variables have to be regarded as escaping for certain function calls. In any case, VOLATILE prevents too much optimizations. The volatile was added by commit: commit 2b4c90656132abb8b8ad155d345c7d4fbf1687c9 via https://gcc.gnu.org/pipermail/gcc-patches/2018-June/499870.html https://gcc.gnu.org/pipermail/gcc-patches/2018-August/503896.html without any discussion of this point.