Silverfrost Forums

Welcome to our forums

Runtime errors produced for error-free code

23 Apr 2022 12:09 #28927

The following test program is error-free.

program packbug
implicit none
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)
print '(12i3)',prm
end program

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

integer :: prm(12)
23 Apr 2022 7:23 #28930

mecej4

Thank you for the bug report which I have logged for investigation.

This relates to the recent addition to FTN95 of 'allocate on assignment' from the Fortran 200x standard.

30 Jul 2022 1:24 #29205

This failure has now been fixed for the next release of FTN95.

Please login to reply.