View previous topic :: View next topic |
Author |
Message |
rudnei
Joined: 29 Dec 2011 Posts: 36
|
Posted: Thu Apr 12, 2018 7:17 pm Post subject: Wrong behaviour of ISHFT |
|
|
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 |
|
|
Kenneth_Smith
Joined: 18 May 2012 Posts: 697 Location: Hamilton, Lanarkshire, Scotland.
|
Posted: Thu Apr 12, 2018 7:40 pm Post subject: |
|
|
This does look like a bug.
Version: 8.30 reproduces this incorrect result.
Ken |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7934 Location: Salford, UK
|
Posted: Thu Apr 12, 2018 8:15 pm Post subject: |
|
|
I have made a note that this needs investigating. |
|
Back to top |
|
|
rudnei
Joined: 29 Dec 2011 Posts: 36
|
Posted: Thu Apr 12, 2018 8:20 pm Post subject: |
|
|
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 |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7934 Location: Salford, UK
|
Posted: Fri Apr 13, 2018 9:15 am Post subject: |
|
|
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 |
|
|
rudnei
Joined: 29 Dec 2011 Posts: 36
|
Posted: Fri Apr 13, 2018 2:26 pm Post subject: |
|
|
Dear Paul,
Many thanks.
Cheers
Rudnei |
|
Back to top |
|
|
|