------- Comment #2 from kargl at gcc dot gnu dot org 2007-01-12 18:10 ------- The Fortran standard has never mandated pass-by-reference in either subroutine or function call. A Fortran compiler can use either pass-by-reference or pass-by-value. In fact, the Standard does not require a Fortran processor to diagnose that the programmer may be doing some stupid.
To understand why this is a stupid thing to do, here's the output from -fdump-tree-original: laptop:kargl[228] more b.f.003t.original MAIN__ () { _gfortran_set_std (70, 127, 0); { static int4 C.989 = 1; sub (&C.989); } sub (i) { *i = *i + 1; goto __return_sub; __return_sub:; The "static int C.989 = 1" is then transformed into this assembly: .file "b.f" .section .rodata .align 4 .LC0: .long 1 .text .globl MAIN__ .type MAIN__, @function MAIN__: pushl %ebp movl %esp, %ebp subl $8, %esp subl $4, %esp pushl $0 pushl $127 pushl $70 call _gfortran_set_std addl $16, %esp subl $12, %esp pushl $.LC0 call sub_ Notice you're trying to modify read-only data. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30450