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 

Compiler bug, caused by use of log_gamma (?)

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



Joined: 31 Oct 2006
Posts: 1885

PostPosted: Tue Oct 11, 2016 1:36 pm    Post subject: Compiler bug, caused by use of log_gamma (?) Reply with quote

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
View user's profile Send private message
PaulLaidler
Site Admin


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

PostPosted: Wed Oct 12, 2016 7:03 am    Post subject: Reply with quote

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
View user's profile Send private message AIM Address
mecej4



Joined: 31 Oct 2006
Posts: 1885

PostPosted: Wed Oct 12, 2016 1:58 pm    Post subject: Re: Reply with quote

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
View user's profile Send private message
PaulLaidler
Site Admin


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

PostPosted: Wed Oct 12, 2016 2:48 pm    Post subject: Reply with quote

Thank you. I think that you are correct so I should not be too difficult to fix.
Back to top
View user's profile Send private message AIM Address
PaulLaidler
Site Admin


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

PostPosted: Fri Jan 20, 2017 11:17 am    Post subject: Reply with quote

This bug has been fixed for the next release.
Back to top
View user's profile Send private message AIM Address
mecej4



Joined: 31 Oct 2006
Posts: 1885

PostPosted: Fri Jan 20, 2017 1:03 pm    Post subject: Reply with quote

I look forward to that release, thanks.
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