Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!linus!philabs!cmcl2!seismo!lll-crg!lll-lcc!qantel!ihnp4!houxm!whuxl!whuxlm!akgua!emory!glenn From: glenn@emory.UUCP (Glenn A. Zazulia) Newsgroups: net.lang.f77,net.bugs.4bsd Subject: Re: Subroutine bug with 4.2 BSD F77. Message-ID: <1651@emory.UUCP> Date: Mon, 16-Jun-86 16:04:33 EDT Article-I.D.: emory.1651 Posted: Mon Jun 16 16:04:33 1986 Date-Received: Tue, 24-Jun-86 03:47:51 EDT References: <3174@sjuvax.UUCP> Reply-To: glenn@emory.UUCP (Glenn A. Zazulia) Distribution: net Organization: Math & Computer Science, Emory University, Atlanta Lines: 40 Xref: linus net.lang.f77:484 net.bugs.4bsd:1873 In article <3174@sjuvax.UUCP> version B 2.10.2 9/18/84; site emory.UUCP version B 2.10.2 9/5/84; site sjuvax.UUCP emory!akgua!akguc!mtune!mtuxo!houxm!mhuxt!mhuxr!ulysses!allegra!princeton!astrovax!sjuvax!bbanerje bbanerje@sjuvax.UUCP (B. Banerjee) writes: >Description: > > User defined functions always return a value of 0 (including > logical functions). > >Repeat-By: > > Compile and execute the following program. >============================================================ > integer i > i = 1 > print *, bug(i) > stop > end > > > integer function bug(i) > integer i > > bug = 2 > return > end > >Fix: > Hopefully fixed in 4.3 BSD. There is no bug here! You forgot to declare your function 'bug' to be of type integer in MAIN. Without the declaration, the function 'bug' will pass back an integer value, but be interpreted as real in MAIN (implicitly typed as such). Remember that the default type of a function, like all variables, whose name begins with any letter other than 'i' - 'n' is real, unless otherwise declared. -- Glenn Zazulia Emory University | {akgua,sb1,gatech,decvax}!emory!glenn USENET Dept of Math and CS | glenn@emory CSNET Atlanta, Ga 30322 | glenn.emory@csnet-relay ARPANET