View previous topic :: View next topic |
Author |
Message |
mecej4
Joined: 31 Oct 2006 Posts: 1897
|
Posted: Wed Mar 10, 2021 1:18 am Post subject: Wrong type argument to intrinsic routine goes undetected |
|
|
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.
Code: | 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,
Code: | s:\lang>test_args xyz |
the response is
Code: | �������������������� |
With /64, the response is a pop up with the message "integer overflow at address ...". |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8036 Location: Salford, UK
|
Posted: Wed Mar 10, 2021 8:53 am Post subject: |
|
|
mecej4
Thank you for the bug report. I have made a note that this needs to be fixed. |
|
Back to top |
|
|
mecej4
Joined: 31 Oct 2006 Posts: 1897
|
Posted: Wed Mar 10, 2021 9:59 am Post subject: |
|
|
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. |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8036 Location: Salford, UK
|
Posted: Wed Mar 10, 2021 12:07 pm Post subject: |
|
|
This failure has now been fixed for the next release of FTN95. |
|
Back to top |
|
|
|