C
Carl Banks
Yes, indeed, and it's quite possible to write code like this in Fortran
that produces exactly this result -- an integer constant gets modified.
This used to get big yucks when we gathered around the keypunch, before we
had the Obfuscated C Contest to amuse us.
Many Fortran compilers these days pass scalars by value by default.
Recently I had to compile a cicra-1972 Fortran program where I had to
disable a lot of recent Fortran innovations (like from 1977) to get it
to build properly. It turned out that it did try to modify a constant
somewhere, but then it segfaulted because the compiler put that
constant in read-only memory.
(Whoever wrote the program originally was a smart cookie, BTW, it was
super versatile for its time.)
Carl Banks