Right, time to declare 'victory', spent too long on reproducing this already.
The following code snippet sneaks the fundamental syntax error past FTN95
program strung_out
use knots
character (len = nb) chintz, chance
chintz = 'xyz'
call charcoal (chance, chintz)
stop
end program strung_out
module knots
integer, parameter :: nb = 3
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)) ! the error is here
end do
chaout = char (inp (2)) // char (inp (3)) // char (inp (1))
end function chaout
end module knots
The resulting /CHECKMATE and /DEBUG builds reproduce the runtime problem as originally reported. The /RELEASE build behaves a little differently, reporting as follows:
*Access Violation
The instruction at address 20202020 attempted to read from location 20202020
20202020 routine at address 20202020 [+0000]
00401000 KNOTS!CHARCOAL [+001e]
004010d0 MAIN [+003c]
eax=0360fc02 ebx=00003a49 ecx=0360fc97
edx=000000fe esi=00402010 edi=0360fd28
ebp=0360fca8 esp=0360fc4c IOPL=0
ds=0023 es=0023 fs=003b
gs=0000 cs=001b ss=0023
flgs=00010a03 [CA OP NZ SN DN OV]*
**NB1 **if subroutine charcoal is listed after function chaout rather than before, all three builds misdiagnose the nature and location of the error in the same way as the previous code snippet. The order has to be as per the code above, to fool the compiler.
**NB2 **if chintz and chance are declared in module knots rather than program strung_out, the runtime behaviour is slightly different:
- /CHECKMATE and /DEBUG builds display source code instead of assembler, and /DEBUG build reports privileged instruction rather than access violation
- /RELEASE build reports access violation a little differently:
*Access Violation
The instruction at address 00404018 attempted to write to location 00003a49
00404018 routine at address 404018 [+0000]
00401000 KNOTS!CHARCOAL [+001e]
004010d0 MAIN [+0048]
eax=0360fca9 ebx=00003a49 ecx=0360fca0
edx=000000fe esi=00402010 edi=0360fd28
ebp=0360fcb0 esp=0360fc54 IOPL=3
ds=0023 es=0023 fs=003b
gs=0000 cs=001b ss=0023
flgs=00010a13 [CA OP NZ SN DN OV]
04040ff outs
00404100 outsb
00404101 cmpb ah,[eax]*