https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95293
--- Comment #7 from Steve Kargl <sgk at troutmask dot apl.washington.edu> --- On Sun, May 24, 2020 at 02:45:32PM +0000, david.sagan at gmail dot com wrote: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95293 > > --- Comment #6 from David Sagan <david.sagan at gmail dot com> --- > > program foo > > real x > > x = 42 > > call bar(x) > > print *, x > > contains > > subroutine bar(a) > > real, intent(inout) :: a > > a = 12 > > x = 0 > > end subroutine bar > > end program foo > > > > Should this print 12 or 0? When bar returns 'a' has a value of > > 12, should this value be transferred to 'x' before the print > > statement is executed? > > 'a' is passed by reference. Therefore, when the statement 'x = 0' is executed, > the value of 'a' immediately changes to 0. So '0' will be printed. > The code, like your original example, is invalid. As this is not a numbered constraint, a Fortran processor is not required to tell a programmer that the program violated the standard. 15.5.2.13 Restrictions on entities associated with dummy arguments While an entity is associated with a dummy argument, the following restrictions hold. (1) Does not apply (2) Does not apply (3) Action that affects the value of the entity or any subobject of it shall be taken only through the dummy argument unless (a) Does not apply (b) Does not apply (c) Does not apply (d) Does not apply