The code below illustrates the third FTN95 v5.50 bug I've reported to ftn95@silverfrost.com this week. To be fair, this one is a variation on the theme of the first one I reported, but I haven't even had either of my first two reports acknowledged yet, and this one is one to beware of, pending an upgrade.
The code below compiles without error, although it does (falsely) offer comment 1036 - The derived-type A has been declared but not used. That's a minor issue.
The major issue is that FTN95 misses the error on the line flagged with the comment '! this minor variant is not' at compile time, and computes without complaining at runtime.
Interestingly, FTN95 does notice an error with the variant statement on the line flagged with the comment ' ! this error is correctly diagnosed'. The error message - error 945: An array cannot be assigned to the scalar WRONG - is not accurate, because what is being assigned to the scalar WRONG is not an array but syntactical nonsense, but at least an error is correctly diagnosed.
Andy
program wrong_answer
integer, parameter :: in_a_dim = 3, in_b_dim = 3
type a
integer in_a (in_a_dim)
end type a
type b
type (a), pointer :: in_b (:) => null ()
end type b
type (b) b_eg
integer ia, ib, wrong
allocate (b_eg% in_b (in_b_dim))
do ia = 1, in_a_dim
do ib = 1, in_b_dim
b_eg% in_b (ib)% in_a (ia) = ia - 1 + (ib - 1)* in_a_dim
end do
end do
wrong = 23
! wrong = wrong + b_eg% in_b (3)% in_a (3) ! this is the correct statement
! wrong = b_eg% in_b% in_a (3) ! this error is correctly diagnosed
wrong = wrong + b_eg% in_b% in_a (3) ! this minor variant is not
stop
end program wrong_answer