Silverfrost Forums

Welcome to our forums

Possible bug in 64 bit SCAN intrinsic function

4 Aug 2017 12:45 #19942

I've encountered a problem when scanning a string for NUL characters using the SCAN intrinsic function.

pos = scan(mystring, char(0))

always returns 0 when compiled with /64, whereas in 32 bit it returns the correct position. I tested with every character from 0-127 but only char(0) produces a wrong result.

See the following program:

program test
    implicit none

    character(10) :: myvar = 'hellohello'
    integer :: i, pos

    do i=0,127
        myvar(5:5) = char(i) ! Replace character
        pos = scan(myvar, char(i))
        if (pos == 0) then
            print '(a,i4,3a)', 'Warning: char', i ,'(', char(i), ') not found, this is not possible.'
        endif
    enddo
end program

Compiled with ftn95.exe /64 .\main.f90 /link, upon execution the output is empty (expected output).

When adding /64, the output is:

Warning: char   0( ) not found, this is not possible.

Regards, André

EDIT: The compiler version is 8.10.0

11 Aug 2017 7:18 #19991

Can someone give me a pointer? Am I misinterpreting something?

11 Aug 2017 10:04 #19993

Char(0) is an end of string character for C strings, so I suspect there is a problem using char(0) with some of the C routines used to implement SCAN. This looks to be a bug in FTN95 /64 If you really need to test for char(0), I'd suggest you equivalence to an INTEGER1 array and search, although there could be problems using INTEGER1 in FTN95 /64 also. If you want a robust approach, try using something other than char(0) !

11 Aug 2017 2:42 #19995

SCAN has now been fixed for the next release.

Please login to reply.