|
forums.silverfrost.com Welcome to the Silverfrost forums
|
View previous topic :: View next topic |
Author |
Message |
Andre
Joined: 19 Jan 2017 Posts: 14
|
Posted: Fri Aug 04, 2017 1:45 pm Post subject: Possible bug in 64 bit SCAN intrinsic function |
|
|
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 |
|
|
Andre
Joined: 19 Jan 2017 Posts: 14
|
Posted: Fri Aug 11, 2017 8:18 am Post subject: |
|
|
Can someone give me a pointer? Am I misinterpreting something? |
|
Back to top |
|
|
JohnCampbell
Joined: 16 Feb 2006 Posts: 2556 Location: Sydney
|
Posted: Fri Aug 11, 2017 11:04 am Post subject: |
|
|
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 |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7931 Location: Salford, UK
|
Posted: Fri Aug 11, 2017 3:42 pm Post subject: |
|
|
SCAN has now been fixed for the next release. |
|
Back to top |
|
|
|
|
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
|