forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Possible bug in 64 bit SCAN intrinsic function

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> 64-bit
View previous topic :: View next topic  
Author Message
Andre



Joined: 19 Jan 2017
Posts: 11

PostPosted: Fri Aug 04, 2017 1:45 pm    Post subject: Possible bug in 64 bit SCAN intrinsic function Reply with quote

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

Code:
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:
Code:

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:
Code:
Warning: char   0( ) not found, this is not possible.


Regards,
André

EDIT: The compiler version is 8.10.0
Back to top
View user's profile Send private message
Andre



Joined: 19 Jan 2017
Posts: 11

PostPosted: Fri Aug 11, 2017 8:18 am    Post subject: Reply with quote

Can someone give me a pointer? Am I misinterpreting something?
Back to top
View user's profile Send private message
JohnCampbell



Joined: 16 Feb 2006
Posts: 1774
Location: Sydney

PostPosted: Fri Aug 11, 2017 11:04 am    Post subject: Reply with quote

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 INTEGER*1 array and search, although there could be problems using INTEGER*1 in FTN95 /64 also.
If you want a robust approach, try using something other than char(0) !
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 4920
Location: Salford, UK

PostPosted: Fri Aug 11, 2017 3:42 pm    Post subject: Reply with quote

SCAN has now been fixed for the next release.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> 64-bit All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group