🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #1862

Re: prototypes required ?

#1862
From: Donald Lewine
Date: Thu, 18 Oct 1990 13:57
48 lines
2892 bytes
In article <12826@crdgw1.crd.ge.com>, volpe@underdog.crd.ge.com
(Christopher R Volpe) writes:
|> 
|> Two questions:
|>   1) Can you point me to a reference in the standard that says that
|>      old-style declarations are insufficient for a variable argument
|>      function in a strictly conforming program? Or are old style
declarations
|>      insufficient for ANY kind of function in a strictly conforming
|>      program?

OK.  See section 3.7.1: "If a function that accepts a variable number
of arguments is defined without a parameter type list that ends with
the ellipsis notation, the behavior is undefined."

This allows the compiler to generate a different calling sequence
for functions with a fixed number of argument and a variable number
of arguments.  See section 4.8 in the rationale.

|> 
|>   2) Are you sure you answered the question he asked? Jeff asked if
|>      it is valid for the compiler to REQUIRE YOU TO include the
|>      prototype. To me, "require you to" means "refuse to generate
|>      code unless you...". That's a different issue. Unless a program
|>      violates a syntax rule or a semantic constraint, the compiler
|>      can at most issue a warning but must still generate code. I
|>      believe (please correct me if I'm wrong) that a program can
|>      fail to be strictly conforming (and even fail to be conforming)
|>      without violating any semantic constraints. Is this correct?
Well, if the implementation uses one calling sequence (say, with
arguments in registers) for functions with a known number of arguments
and uses a different calling sequence (say, with arguments on the
stack) for functions with a variable number of arguments, the 
generated code will not call the library correctly unless the function
is correctly declared.  I will admit that you may not get an error 
message, but the code will not work!
 
Note also that the definition of ANSI C was done to allow a compiler
to generate calls with arguments in registers and several new RISC
compilers take advantage of that.

--------------------------------------------------------------------
Donald A. Lewine                (508) 870-9008 Voice
Data General Corporation        (508) 366-0750 FAX
4400 Computer Drive. MS D112A
Westboro, MA 01580  U.S.A.

uucp: uunet!dg!lewine   Internet: lewine@cheshirecat.webo.dg.com
Technical Details
Message-ID: <1061@dg.dg.com>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rutgers!usc!sdd.hp.com!samsung!uunet!dg!dg-rtp.dg.com!lewine
References: <4026@otis.oakhill.UUCP> <14164@smoke.BRL.MIL> <12826@crdgw1.crd.ge.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rutgers!usc!sdd.hp.com!samsung!uunet!dg!dg-rtp.dg.com!lewine
From: lewine@dg-rtp.dg.com (Donald Lewine)
Newsgroups: comp.std.c
Subject: Re: prototypes required ?
Keywords: printf stdargs prototypes
Message-ID: <1061@dg.dg.com>
Date: 18 Oct 90 13:57:51 GMT
References: <4026@otis.oakhill.UUCP> <14164@smoke.BRL.MIL> <12826@crdgw1.crd.ge.com>
Sender: root@dg.dg.com
Reply-To: uunet!dg!lewine
Organization: Data General Corporation
Lines: 48