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 

Wrong behaviour of ISHFT

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support
View previous topic :: View next topic  
Author Message
rudnei



Joined: 29 Dec 2011
Posts: 30

PostPosted: Thu Apr 12, 2018 7:17 pm    Post subject: Wrong behaviour of ISHFT Reply with quote

Hi,
I found today that ISHFTing bits to the right does not give the right answer when the first argument is a PARAMETER, as per the following program:

program test_ishft
implicit none
integer, parameter :: n_par=20
integer :: n=20
integer :: n_double,n_half
n_double=ishft(n,1)
n_half=ishft(n,-1)
print *,n_double,n_half ! correct: prints 40 and 10
n_double=ishft(n_par,1)
n_half=ishft(n_par,-1)
print *,n_double,n_half ! error: prints 40 and 0 (!!)
end program test_ishft

compilation gives no errors:

$ ftn95 test_ishift.f95
[FTN95/Win32 Ver. 8.10.0 Copyright (c) Silverfrost Ltd 1993-2017]
Licensed to: Rudnei Dias da Cunha
Organisation: UFRGS

NO ERRORS [<TEST_ISHFT> FTN95 v8.10.0]

but the results given are:

40 10
40 0

Also, this is the system I am working on:
$ ftn95 /v

Silverfrost FTN95/Win32 Copyright (C) 1993-2017 Silverfrost Ltd
----------------------------------------------------------------

Version: 8.10.0
Built: Sat Feb 11 12:23:39 2017

Operating System: Windows NT CPU: Intel(R) Core(TM) i5-6400T CPU @ 2.20GHz Model 14 Step 3
CPU Features: MMX, SSE, SSE2, x86-64

Thanks for looking into it!
Cheers
Rudnei
Back to top
View user's profile Send private message
Kenneth_Smith



Joined: 18 May 2012
Posts: 175
Location: Glasgow, Scotland.

PostPosted: Thu Apr 12, 2018 7:40 pm    Post subject: Reply with quote

This does look like a bug.
Version: 8.30 reproduces this incorrect result.

Ken
Back to top
View user's profile Send private message Visit poster's website
PaulLaidler
Site Admin


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

PostPosted: Thu Apr 12, 2018 8:15 pm    Post subject: Reply with quote

I have made a note that this needs investigating.
Back to top
View user's profile Send private message
rudnei



Joined: 29 Dec 2011
Posts: 30

PostPosted: Thu Apr 12, 2018 8:20 pm    Post subject: Reply with quote

I have just found out that

n_double=ishft(20,1)
n_half=ishft(20,-1)
print *,n_double,n_half ! error: prints 40 and 0 (!!)

also fails...
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


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

PostPosted: Fri Apr 13, 2018 9:15 am    Post subject: Reply with quote

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

(Internally the two cases are the equivalent, both being evaluated at compile time.)
Back to top
View user's profile Send private message
rudnei



Joined: 29 Dec 2011
Posts: 30

PostPosted: Fri Apr 13, 2018 2:26 pm    Post subject: Reply with quote

Dear Paul,
Many thanks.
Cheers
Rudnei
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 -> Support 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