mecej4
Joined: 31 Oct 2006 Posts: 1886
|
Posted: Sun Oct 14, 2018 2:13 pm Post subject: False runtime error for allocatable arrays in WHERE block |
|
|
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
Code: | 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
Code: | 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.
Code: | 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 |
Last edited by mecej4 on Mon Oct 15, 2018 12:56 pm; edited 1 time in total |
|