Thread View: net.lang.f77
11 messages
11 total messages
Started by B. Banerjee
Fri, 13 Jun 1986 15:29
Subroutine bug with 4.2 BSD F77.
Author: B. Banerjee
Date: Fri, 13 Jun 1986 15:29
Date: Fri, 13 Jun 1986 15:29
25 lines
961 bytes
961 bytes
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.
Re: Subroutine bug with 4.2 BSD F77.
Author: Doug Gwyn
Date: Sun, 15 Jun 1986 04:25
Date: Sun, 15 Jun 1986 04:25
9 lines
826 bytes
826 bytes
> print *, bug(i) At this point, bug() is assumed to be a real-valued function. > integer function bug(i) But now you define it incompatibly. Too bad the compiler doesn't report an error for this.
Re: Subroutine bug with 4.2 BSD F77.
Author: Comfy chair
Date: Mon, 16 Jun 1986 15:20
Date: Mon, 16 Jun 1986 15:20
31 lines
1102 bytes
1102 bytes
>Description:
>
> User defined functions always return a value of 0 (including
> logical functions).
Fix:
integer i
+ integer bug
i = 1
print *, bug(i)
stop
end
integer function bug(i)
integer i
bug = 2
return
end
>Fix:
> Hopefully fixed in 4.3 BSD.
Meta-fix:
Read the Fortran standard.
Ken
--
UUCP: ..!{allegra,decvax,seismo}!rochester!ken ARPA: ken@rochester.arpa
Snail: CS Dept., U. of Roch., NY 14627. Voice: Ken!
Re: Subroutine bug with 4.2 BSD F77.
Author: B. Banerjee
Date: Mon, 16 Jun 1986 16:39
Date: Mon, 16 Jun 1986 16:39
44 lines
1804 bytes
1804 bytes
In article <3174@sjuvax.UUCP> I wrote:
>> 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.
I'm sorry people. As has been pointed out to me by various people,
one needs a forward declaration of bug in order to over-ride the
default typing of Fortran.
This was brought to my attention by a local user. My previous
experience with Fortran has been with Fortran IV in the old days
of punched cards. Both the compilers I used previously would have
accepted the above without problem. I guess that they just used
extensions.
My apologies to anyone inconvenienced by the above posting.
Regards,
Binayak Banerjee
{allegra | astrovax | bpa | burdvax}!sjuvax!bbanerje
bbanerje@sju.edu
Re: Subroutine bug with 4.2 BSD F77.
Author: sjc
Date: Mon, 16 Jun 1986 18:36
Date: Mon, 16 Jun 1986 18:36
24 lines
1300 bytes
1300 bytes
> User defined functions always return a value of 0 (including > logical functions). > > integer i > i = 1 > print *, bug(i) > stop > end > > integer function bug(i) > integer i > bug = 2 > return > end Because "bug" begins with the letter "b", the main program thinks that its type is "real", despite the later definition of it as "integer". Change "integer i" to "integer i, bug" in the main program and your program will work. (This is ANSI X3.9-1978 Fortran, not a bug: when the compiler processes program unit "x", it is not allowed to use any knowledge it may have about program unit "y", even if "x" and "y" appear in the same file--even if "y" precedes "x" in the file.) -- ...decwrl!mips!sjc Steve Correll
Re: Subroutine bug with 4.2 BSD F77.
Author: Glenn A. Zazulia
Date: Mon, 16 Jun 1986 20:04
Date: Mon, 16 Jun 1986 20:04
40 lines
1964 bytes
1964 bytes
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
Re: Subroutine bug with 4.2 BSD F77.
Author: Bill Anderson
Date: Tue, 17 Jun 1986 19:09
Date: Tue, 17 Jun 1986 19:09
31 lines
1135 bytes
1135 bytes
> 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. You need to specify the type for bug (i.e. integer bug). Bill Anderson, NBS ...!seismo!nbs-amrf!anderson
Re: Subroutine bug with 4.2 BSD F77.
Author: Jim Thompson
Date: Wed, 18 Jun 1986 11:18
Date: Wed, 18 Jun 1986 11:18
48 lines
1408 bytes
1408 bytes
In article <3174@sjuvax.UUCP> bbanerje@sjuvax.UUCP 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.
Add this little bit and it runs just fine, thank you. :-)
integer i,bug
(prints '2')
Now, is this a bug or a feature?
The same 'bug' exists in VMS fortran.
(And the same fix applies.)
--
Jim Thompson
{ihnp4,sdcrdcf}!otto!jim
[ Usual disclamer: I have no opinion, therefore I don't exist .]
Re: Subroutine bug with 4.2 BSD F77.
Author: Jim Thompson
Date: Wed, 18 Jun 1986 11:31
Date: Wed, 18 Jun 1986 11:31
39 lines
1385 bytes
1385 bytes
In article <3174@sjuvax.UUCP> bbanerje@sjuvax.UUCP writes:
>Description:
>
> User defined functions always return a value of 0 (including
> logical functions).
>
>Repeat-By:
>
> Compile and execute the following program.
>============================================================
> integer i
C>>>>>>>>>>>>>>>>>>insert this:
integer bug
C>>>>>>>>>>>>>>>>>>end of fix.
> i = 1
k>
>Fix:
> Hopefully fixed in 4.3 BSD.
Now the only remaining question is:
Is this really a bug?
Note: VMS fortran does the same thing. Namely,
if bug is declaired then the proper result ('2') is printed.
If not, both output a '0'.
--
Jim Thompson
{ihnp4,sdcrdcf}!otto!jim
[ Usual disclamer: I have no opinion, therefore I don't exist .]
Re: Subroutine bug with 4.2 BSD F77.
Author: Jim Thompson
Date: Wed, 18 Jun 1986 11:35
Date: Wed, 18 Jun 1986 11:35
39 lines
1236 bytes
1236 bytes
In article <3174@sjuvax.UUCP> bbanerje@sjuvax.UUCP 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.
insert ',bug' in line one.
--
Jim Thompson
{ihnp4,sdcrdcf}!otto!jim
[ Usual disclamer: I have no opinion, therefore I don't exist .]
Re: Subroutine bug with 4.2 BSD F77.
Author: Walter M. Lioen
Date: Mon, 23 Jun 1986 17:34
Date: Mon, 23 Jun 1986 17:34
33 lines
1319 bytes
1319 bytes
In article <3174@sjuvax.UUCP> bbanerje@sjuvax.UUCP 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.
Fix: %s/bug/nobug/g
--
Mail: Walter M. Lioen, CWI, P.O. Box 4079, 1009 AB Amsterdam, The Netherlands.
UUCP: {seismo,decvax,philabs,okstate,garfield}!mcvax!walter
or: walter@mcvax.uucp
ARPA: walter%mcvax.uucp@seismo.css.gov
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads