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 

Bad code generated with /undef or /checkmate

 
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: 1024

PostPosted: Tue Oct 02, 2018 5:41 pm    Post subject: Bad code generated with /undef or /checkmate Reply with quote

For the test program below, the expected output result is " slope = 7.00000". FTN95 8.30, 32 and 64 bit, gives this result except when /undef or /checkmate is used, in which case the erroneous output "slope = 0.00000" is produced. Versions 7.2 and 6.35 do not have this bug.
Code:
program ex2
   implicit none
   integer :: m = 5, j1
   real , dimension(5) :: x, alpha
   real :: slope, prdct
   real, allocatable    :: r1v(:)
   logical, allocatable :: l1v(:)
!
   data x     / -2.0,  -1.0,  1.0,  2.0,  4.0 /
   data alpha / -1.0,  -7.0,  7.0,  5.0,  3.0 /
   data prdct /  1.5 /
!
   slope  = 0.
   allocate (l1v(m), r1v(m))
   l1v = (/(j1, j1=1, m)/) /= 1
   where (l1v)
      r1v = (alpha(1) + alpha)/(x(1) - x)
   elsewhere
      r1v = 0
   end where
   slope = (slope + sum(r1v, mask=l1v))*prdct
   deallocate (l1v, r1v)
   print *,'slope = ',slope
   stop
end program

Inspecting the 32-bit /exp listing shows that the problem is with the code generated for the WHERE construct. The address of L1V is held in register ECX. After each iteration of the block, ECX should be incremented by 4, but this instruction is missing. As a result, the mask used is L1V(1), L1V(1),... instead of L1V(1), L1V(2), ...

A strange example of an anti-Heisenbug!
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


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

PostPosted: Wed Oct 03, 2018 7:26 am    Post subject: Reply with quote

Thank you for this bug report. I have logged this for investigation.
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