mrs@philabs.Philips.Com (Member Research Staff) (01/08/88)
While trying to port a program from VMS to UNIX I ran across the following
bug in the UNIX 4.3 BSD f77 compiler. (This subroutine isn't meant to
do anything but display the bug). Here is the file:
% cat foo.f
subroutine getc(char)
character char,chas*(*)
integer n
c
return
entry gets(chas,n)
return
end
and the error message I get is:
% f77 foo.f
foo.f
getc:
Error on line 2 of foo.f: Declaration error for chas: illegal adjustable length character variable
entry gets:
Error. No assembly.
--------------------
The file compiles correctly using the following machines, operating systems:
IBM/CMS fortran compilier
VAX/VMS fortran compilier
SUN UNIX 4.2 Release 3.4 f77 compilier
Does anyone on the net have a fix for this bug.
Thanks
Mark R. Simpson
Philips Laboratories uunet!philabs!mrs
North American Philips Corporation or
Briarcliff Manor, NY 10510 mrs@philabs.philips.com
(914) 945-6163perry@vu-vlsi.UUCP (Rick Perry) (01/12/88)
In article <3124@briar.Philips.Com> mrs@philabs.Philips.Com (Mark R. Simpson) writes: >.. >% cat foo.f > subroutine getc(char) > character char,chas*(*) >.. >Error on line 2 of foo.f: Declaration error for chas: illegal adjustable length character variable Although your original routine did compile ok here (Pyramid 90x OSx4.0) I have had problems in the past with this type of thing and found that having a dummy routine name which includes all of the entry point arguments made the compiler happy, i.e. subroutine getcs(char,chas,n) character char,chas*(*) integer n entry getc(char) return entry gets(chas,n) return end ...Rick perry@vu-vlsi.UUCP, perry@vuvaxcom.BITNET Dr. Rick Perry, Department of Electrical Engineering Villanova University, Villanova, PA 19085, 215-645-4969, -4970
mrs@spectrum.UUCP (01/17/88)
In my original article, I noted a bug in the UNIX 4.3 f77 compilier
with the entry statement. A number of people replied with suggestions
on how to circumvent the difficulty, but they all involved either
1) changing the calling sequence, or 2) not using the entry
statement. The simplist modification (of cousre I maybe biased since it
is the one I used) is to make use of fortran's
"call by location" argument passing. Specifically, the declaration
character chas*(*)
is "equivalent" (and I use the form loosely) to
character chas*1
since in both instances the location of chas is passed to the calling
routine. Consequently, I neither have to change the calling sequence
or remove the entry statement and the code is compatible
across machines/operating systems. I agree, nevertheless, that the use
of the entry statement goes against the grain of structured programming.
Here is the revised subroutine which now compilies.
subroutine getc(char)
c old statement
c character char,chas*(*)
c new statement
character char,chas*1
integer n
c
return
entry gets(chas,n)
return
end
Mark R. Simpson
Philips Laboratories uunet!philabs!mrs
North American Philips Corporation or
Briarcliff Manor, NY 10510 mrs@philabs.philips.com
(914) 945-6163
Mark R. Simpson
Philips Laboratories uunet!philabs!mrs
North American Philips Corporation or
Briarcliff Manor, NY 10510 mrs@philabs.philips.com
(914) 945-6163