Please can someone have a look at this little program and tell me whether it is me or FTN95 that is being very stupid?
Step into the subroutine and observe carefully. The automatic character variable charac does not get assigned, character by character, to char (0). Instead, as soon as the assignment statement is hit for the first time, characters 5 to 10 of charac get set to something different, and charac does not change for the rest of the loop. When the end of the subroutine is reached, charac reverts to what it was on entry.
I can't see anything wrong with the code, but equally I can't believe that a compiler bug this blatant would have escaped detection 😒hock:
program deferred
integer size
size = 4
call sub (size)
end program deferred
subroutine sub (n)
integer i, n
character (len = n) :: charac
do i = 1, n
charac (i: i) = char (0)
end do
end subroutine sub