View previous topic :: View next topic |
Author |
Message |
mecej4
Joined: 31 Oct 2006 Posts: 1886
|
Posted: Tue Oct 11, 2016 1:36 pm Post subject: Compiler bug, caused by use of log_gamma (?) |
|
|
FTN95 8.05 outputs an erroneous result for the first run of the DO loop and then aborts with an X87 stack fault when the following program is compiled and run in 32-bit mode. There is no error with /64. I am not sure whether the bug is directly related to the use of the F2008 function log_gamma. The bug goes away if log_gamma is replaced by log.
Code: |
program xloggam
implicit none
real :: p,q(2),x
integer :: ifault,i
data p/2.0/, q /10.0,20.0/
do i=1,2
x = log_gamma(p)+log_gamma(q(i))-log_gamma(p+q(i))
write(*,10)q(i),x
end do
10 format(F8.0,ES16.8)
end program
|
If the unused variable ifault is removed, the output for i = 1 is changed, although still incorrect. |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7925 Location: Salford, UK
|
Posted: Wed Oct 12, 2016 7:03 am Post subject: |
|
|
Thank you for the feedback. I have logged this as a bug that needs fixing.
I can get it to work if the 3 log_gamma results are stored separately and then combined. |
|
Back to top |
|
|
mecej4
Joined: 31 Oct 2006 Posts: 1886
|
Posted: Wed Oct 12, 2016 1:58 pm Post subject: Re: |
|
|
PaulLaidler wrote: | I can get it to work if the 3 log_gamma results are stored separately and then combined. |
Thanks Paul. Yes, storing the result of each term in memory would reduce the chance of X87 stack overflow, but if the CDECL calling convention applies, " registers ST0 to ST7 must be empty (popped or freed) when calling a new function, and ST1 to ST7 must be empty on exiting a function" (quoting from Wikipedia). Therefore, two or three registers should suffice to evaluate the expression, unless log_gamma is inlined. |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7925 Location: Salford, UK
|
Posted: Wed Oct 12, 2016 2:48 pm Post subject: |
|
|
Thank you. I think that you are correct so I should not be too difficult to fix. |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7925 Location: Salford, UK
|
Posted: Fri Jan 20, 2017 11:17 am Post subject: |
|
|
This bug has been fixed for the next release. |
|
Back to top |
|
|
mecej4
Joined: 31 Oct 2006 Posts: 1886
|
Posted: Fri Jan 20, 2017 1:03 pm Post subject: |
|
|
I look forward to that release, thanks. |
|
Back to top |
|
|
|