Joined: 31 Oct 2006
|Posted: Sat Apr 23, 2022 1:09 am Post subject: Runtime errors produced for error-free code
|The following test program is error-free.
integer :: pci(20)
integer, allocatable :: prm(:)
pci = [3,5,7,0,11,13,0,17,19,0,23,0,0,29,31,0,0,37,0,41]
prm = pack(pci, pci > 0)
print '(A,2x,I2)','Count of nonzero entries = ',size(prm)
The expected output is
|Count of nonzero entries = 12
3 5 7 11 13 17 19 23 29 31 37 41
When the code is compiled with ftn95 8.84 with just /debug, linked and run, the program aborts with "*** Error 416: Bad request for stack memory"
When compiled with /64 /debug, linked and run, the program aborts with an access violatation on line-6.
When compiled with /check, linked and run, the program aborts with "Error: Reference through NULL Fortran POINTER".
When the options /check /64 are used, the program runs to completion, but gives the incorrect output:
|Count of nonzero entries = 0 |
The bugs go away if the declaration of the array variable prm is changed to