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 Assigned GOTO and /save

 
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: Sun Apr 23, 2017 11:15 pm    Post subject: Bad code generated with Assigned GOTO and /save Reply with quote

A large program (http://plato.asu.edu/ftp/other_software/dqed.f.gz), dating back to the 1980-s, contains Assigned GOTO statements and also requires the /save compiler option. The following tiny program reproduces the bug that I encountered when I used the 32-bit FTN95 8.10 on the DQED program.
Code:
      program AsgGoto
      implicit none
      integer nv
      nv = 8
      call dqed(nv)
      print *,'Returned to main'
      end
!
      subroutine dqed(nvars)
      implicit none
      integer nvars,igk
      integer, save :: iflag = 0
      assign 40 to igk
      if (iflag.eq.0) then
          if (nvars.le.0) then
              assign 50 to igk
          end if
      end if
      goto igk
   40 iflag=iflag+1
      return
   50 stop 'xyz'
      end

The two ASSIGN statements result in code similar to
Code:
mov dword ptr [00000024], 004010D0

instead of
Code:
mov dword ptr [00400024], 004010D0

As a result of this, the program aborts with an illegal access to address 00000024.

The test program should function the same way whether /save is used or not, but the bug occurs only when /save is used.

The 64-bit compiler does not have this problem.
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


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

PostPosted: Mon Apr 24, 2017 6:48 am    Post subject: Reply with quote

Thank you. I have made a note that this needs fixing.
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: Wed Aug 21, 2019 7:23 am    Post subject: Reply with quote

This failure has now been fixed for the next release of FTN95.
Back to top
View user's profile Send private message AIM Address
LitusSaxonicum



Joined: 23 Aug 2005
Posts: 2388
Location: Yateley, Hants, UK

PostPosted: Fri Aug 23, 2019 3:43 pm    Post subject: Reply with quote

Truly, Mecej4, you never cease to surprise.

May I remind you of the adage "He who sups with the Devil should use a long spoon" ? It's particularly apt when sampling various bits of Fortran from the Internet.

ASSIGNED GOTOs may well be still supported by FTN95, even though they have been marked for deletion (of which I disapprove, naturally), and usually, there are far better ways of doing that particular job.

But worse still is the need for SAVE. This has been the mark of someone who ignores the rules, as written down on tablets of stone by the Holy Backus in the Beginning, and is therefore not to be trusted.

Eddie
Back to top
View user's profile Send private message
John-Silver



Joined: 30 Jul 2013
Posts: 1520
Location: Aerospace Valley

PostPosted: Fri Aug 23, 2019 11:06 pm    Post subject: Reply with quote

Well done Paul, another bug bites the dust
_________________
''Computers (HAL and MARVIN excepted) are incredibly rigid. They question nothing. Especially input data.Human beings are incredibly trusting of computers and don't check input data. Together cocking up even the simplest calculation ... Smile "
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