Silverfrost Forums

Welcome to our forums

Wrong type argument to intrinsic routine goes undetected

10 Mar 2021 12:18 #27261

The following code mistakenly passes a 2-byte integer as the first argument to the intrinsic subroutine GET_COMMAND_ARGUMENT. The 8.70 compiler does not detect this error, even if /CHECK or /CHECKMATE is specified.

program test_args
implicit none
character carg*20
integer icount
integer*2 i2           !wrong integer size for arg to GET_COMMAND_ARGUMENT
!
iCount = 1 + COMMAND_ARGUMENT_COUNT()
if(iCount.gt.1) then
   i2 = 1
   call GET_COMMAND_ARGUMENT(i2, carg)
   print *,trim(carg)
endif
end program

When this code is compiled for 32-bit and run with one argument,

s:\lang>test_args xyz

the response is

 ÇÇÇÇÇÇÇÇÇÇÇÇÇÇÇÇÇÇÇÇ

With /64, the response is a pop up with the message 'integer overflow at address ...'.

10 Mar 2021 7:53 #27262

mecej4

Thank you for the bug report. I have made a note that this needs to be fixed.

10 Mar 2021 8:59 #27263

The reason for the wrong argument type is that many codes developed in the 1990s used the Microsoft extensions NARGS, GET_ARG, GET_DATE and GET_TIME. At that time, standard Fortran did not provide the functionality of these routines. The 2-byte integers used as arguments for these extensions were appropriate for the 16-bit compilers of the day.

Unless one is on the lookout for INTEGER*2 declarations, which I was not, one can get into trouble, as I did.

10 Mar 2021 11:07 #27264

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

Please login to reply.