Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 16 Aug 1999 10:00:02 -0700 (PDT)
From:      "Steven G. Kargl" <kargl@apl.washington.edu>
To:        freebsd-bugs@FreeBSD.org
Subject:   Re: bin/12431: f2c works incorrectly with arguments of subroutine with  multiple entry points
Message-ID:  <199908161700.KAA84932@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
The following reply was made to PR bin/12431; it has been noted by GNATS.

From: "Steven G. Kargl" <kargl@apl.washington.edu>
To: freebsd-gnats-submit@freebsd.org, dima@server.ru
Cc:  
Subject: Re: bin/12431: f2c works incorrectly with arguments of subroutine with 
 multiple entry points
Date: Mon, 16 Aug 1999 09:53:18 -0700

 The PR should be closed.  Upon closer inspection it appears that the 
 Dima's codes relies on undefine behavour.
 
       subroutine a(x,y,z)
       z=x+y
       return
       entry b(i)
       i=z
       return
       end
 
       program main
       call a(1.,2.,z)
       write(*,*) z
       call b(i)
       write(*,*) i
       stop
       end
 
 Z is a dummy argument to subroutine a().  Z goes out of scope
 when a() returns to main.  When b() is called, z is an undefined
 variable.
 
 The correct fix is:
 
       subroutine a(x,y,z)
       real zz
       save zz
       data zz /0./
       z=x+y
       zz=z
       return
       entry b(i)
       i=zz
       return
       end
 
 because the SAVE attribute can be used on local variables while
 it can not be used with dummy variables.
 
 -- 
 Steve
 


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199908161700.KAA84932>