The program below contains one error: line-22 has chainp(b) instead of chainp(b:b). The bug is not difficult to diagnose at compile time, as Gfortran and NAG do.
FTN95 /64 /checkmate produces an EXE that crashes with an access violation when run. FTN95 /checkmate produces a 32-bit EXE that crashes with 'Attempt to execute privileged instruction'. FTN95 /opt leads to '...attempted to write to location 00000001'. In other words, the bug is not caught at compile or run time, even with /checkmate.
The test program is a modification of an earlier submission by user 'Sparge' in 2011, see https://forums.silverfrost.com/Forum/Topic/1689&highlight=attempted+access+location .
program strung_out
implicit none
integer, parameter :: nb = 3
character (len = nb) chintz, chance
chintz = 'xyz'
call charcoal (chance, chintz)
print *,chance
stop
contains
subroutine charcoal (champ, chimp)
character (len = nb) champ, chimp
champ = chaout (chimp)
end subroutine charcoal
character (len = nb) function chaout (chainp)
character (len = nb) chainp
integer b, inp (nb)
do b = 1, nb
inp (b) = ichar (chainp (b)) ! ***ERROR***
! inp (b) = ichar (chainp (b:b)) ! ***CORRECT***
end do
chaout = char (inp (2)) // char (inp (3)) // char (inp (1))
end function chaout
end program strung_out