On Sun, 31 May 2020, Eric Korpela via cctalk wrote:
C
C CHANGE THE VALUE OF 4
C
CALL INC(4)
WRITE (*, 30) 4
30 FORMAT ('2+2=',I4)
END
SUBROUTINE INC(I)
I = I + 1
END
-------- OUTPUT
2+2= 5
Hmm, as a matter of interest I fed this program to current trunk GCC and
with an x86/Linux system it crashes at the incrementation of the literal,
because the value has been assigned to a read-only memory segment. With a
RV64/Linux system it works as expected as the compiler gives priority to
data assignment to the small data area over the read-only attribute, but
I'd call it luck rather than intent.
GCC supports legacy Fortran code, so I have filed PR fortran/95631 to
track this bug, at: <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95631>.
Let's see what emerges.
Thanks for sharing this peculiarity with us!
Maciej