Silverfrost Forums

Welcome to our forums

False runtime error for allocatable arrays in WHERE block

14 Oct 2018 1:13 (Edited: 15 Oct 2018 11:56) #22668

The following code does some simple operations with allocatable array variables and uses them in a WHERE construct. The program is free of errors and the expected output is ' F T T'. With FTN95, we do get the correct output with or without /64, with or without /check, as long as /checkmate is not specified. When /checkmate is used, the 32-bit EXE crashes with

Access Violation
The instruction at address 00401495 attempted to read from location 024251fc in file tmsk.f90 at line 16

 TMASK -  in file tmsk.f90 at line 16 [+0495]

[P.S.: Note that the reported line number of the crash is wrong. It should actually be 18, as can be seen by locating the crashing machine instruction, and as reported with /64 below.]

Similarly, with /checkmate the 64-bit EXE crashes with

Access violation (c0000005) at address 401c12

Within file tmsk.EXE
in TMASK in line 18, at address 722

The crashes do not occur if the arrays are allocated statically.

Here is the source code for the test program.

program tmask
   implicit none
   integer, allocatable :: KAu(:)
   logical, allocatable :: LAv(:), LBv(:)
   real, allocatable    :: TAu(:)
   integer :: n, nf, naa, nc
   integer :: iaa(4) = [1, 6, 5, 4]
   integer :: ia(10) = [-2, 2, 2, 2,-2, -2, 1, 6, 5, 4]
   !
   nf = 3; n = 0; nc = 2
   naa = nf - n
   Allocate (KAu(naa), TAu(naa), LAv(naa), LBv(naa))
   LBv = .false.
   KAu = iaa(:naa)
   LAv = KAu > nc
   where (LAv)
      TAu = 1.0
      LBv = ia(KAu) == (-2) .or. ia(KAu) == (-4)
   end where
   where (LBv)
      TAu = -TAu
   end where
   print '(8L4)', LBv
end program
15 Oct 2018 6:37 #22674

Thank you for this report. I can confirm that this is still an issue and needs investigating.

21 Jan 2019 10:11 #23133

These bugs have now been fixed for the next release of FTN95.

Please login to reply.