[net.lang.c] static arguments

ron@njitcccc.UUCP (Ron DeBlock) (05/31/86)

A new member of our staff was recently having problems with a set of functions
he was writing.  Our system is a 3B5 running UNIX System V Realease 2.

He accidently declared the arguments to his function as static, like so:

struct whatever *foobar(arg1,arg2)
static char *arg1, *arg2;
{
	.
	.
	.
}

I realize that it really makes no sense to do that, but the compiler did not
flag the "error".  The only indication of the problem was when ld complained
that ".L157" and ".L158" were undefined symbols.  The only place where I've
seen symbol names like that is the assembly output of the compiler so I checked
that.  The undefined symbols were found in a section which seemed to reference
the arguments, which led me to the problem.

The question is, are static arguments legal even though they make no sense?
If not, why doesn't the compiler flag the problem?  If they are legal, have
we discovered a bug in our linker?

Thanks in advance for any enlightening information.
-- 
Ron DeBlock
New Jersey Institute of Technology
Computerized Conferencing and Communications Center
Newark, NJ 07102

	uucp: ...!allegra!bellcore!njitcccc!ron
	      ...!andromeda!njitcccc!ron
	arpa: njitcccc!ron@bellcore.arpa
	bitnet: ron%njitcccc.bitnet

"Beware of programmers carrying screwdrivers."

chris@umcp-cs.UUCP (Chris Torek) (05/31/86)

In article <170@njitcccc.UUCP> ron@njitcccc.UUCP (Ron DeBlock) writes:
>[Someone] accidently declared the arguments to his function as
>static [...].  I realize that it really makes no sense to do that,
>but the compiler did not flag the "error". [...]  The question is,
>are static arguments legal even though they make no sense?

No.

>If not, why doesn't the compiler flag the problem?

It is buggy.  The 4.3BSD C compiler, whatever its faults, gets this
one right: it complains about an `illegal class'.
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 1516)
UUCP:	seismo!umcp-cs!chris
CSNet:	chris@umcp-cs		ARPA:	chris@mimsy.umd.edu

ricmtodd@uok.UUCP (06/04/86)

/* Written  5:46 pm  May 30, 1986 by ron@njitcccc.UUCP in uok.UUCP:net.lang.c */
>The question is, are static arguments legal even though they make no sense?
>If not, why doesn't the compiler flag the problem?  If they are legal, have
>we discovered a bug in our linker?
>
>Thanks in advance for any enlightening information.
>-- 
>Ron DeBlock
>New Jersey Institute of Technology
>Computerized Conferencing and Communications Center
>Newark, NJ 07102
>
>	uucp: ...!allegra!bellcore!njitcccc!ron
>	      ...!andromeda!njitcccc!ron
>	arpa: njitcccc!ron@bellcore.arpa
>	bitnet: ron%njitcccc.bitnet
/* End of text from uok.UUCP:net.lang.c */

Quoting from Appendix A of Kernighan and Ritchie, p. 203, about argument lists:
     "The only storage class which may be specified is register; . . ."
Thus static arguments are indeed illegal.
A couple of quick tests show that both the compiler on uok (BSD 2.9) and the
compiler on my PC (Aztec C) object to static declared arguments. The BSD
UNIX compiler gives:

temp.c:1: Conflict in storage class
temp.c:1: x redeclared

Aztec C gives an "Internal Error" message. Not very informative, but it does
at least point a caret at the offending declaration.

                          Richard Todd
                          {allegra!cbosgd|ihnp4}!okstate!uokvax!uok!ricmtodd