Article View: comp.std.c
Article #4152Re: Composite type of incompatible parameter types
From: Thad Smith
Date: Sun, 01 Oct 1995 22:27
Date: Sun, 01 Oct 1995 22:27
58 lines
2203 bytes
2203 bytes
In article <44h3ak$p3j@newshost.lanl.gov>,
tanmoy@qcd.lanl.gov (Tanmoy Bhattacharya) wrote:
>By the way, does this mean that that after
>
>int f(const int);
>int g(const int);
>int g(const int);
>
>f has type int(const int) because types do not need to be composed: there is
>only one declaration, but g has type int(int)? Maybe, but it does not have
>any observable effects yet.
A few years ago it was suggested on the Fidonet C Echo that the
declaring a parameter const could be used by an optimizing compiler to
avoid redundant parameter loading in consecutive calls:
void f(const double a, const int b);
void g(const double a, const int b);
...
f(x, y);
g(x, y);
might be optimized (using stack for parameters) from
PUSHINT y
PUSHFLT x
CALL f
DECRSP (length x + length y)
PUSHINT y
PUSHFLT x
CALL g
DECRSP (length x + length y)
to:
PUSHINT y
PUSHFLT x
CALL f
CALL g
DECRSP (length x + length y)
>|> Technical Corrigendum 1 says that "In the determination of type
>|> compatibility and of a composite type, ... each parameter declared with
>|> qualified type is taken as having the unqualified version of its declared
>|> type." So does that means that
>
>Note that the sentence does not apply to the determination of the type of
>parameter `a': it applies to determination of the compatibility and
>the composite type of the function. In absence of any specific statement to
>the contrary, `a' continues to be `const int' (even though the composite
>function type is void(int).)
If parameters a and b in my example need not be const in the
implemention of f, as your analysis suggests, the proposed
optimization would fail.
Thad
Technical Details
Message-ID:
<8ptbwQ9ytNkL084yn@csn.net>Path:
arc1-ca.pugleaf.net!teal.csn.net!not-for-mailReferences:
<44fkc3$hj3@news0.rain.rg.net> <44h3ak$p3j@newshost.lanl.gov>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!teal.csn.net!not-for-mail From: thads@csn.net (Thad Smith) Newsgroups: comp.std.c Subject: Re: Composite type of incompatible parameter types Date: 1 Oct 1995 16:27:27 -0600 Organization: T3 Systems Distribution: world Message-ID: <8ptbwQ9ytNkL084yn@csn.net> References: <44fkc3$hj3@news0.rain.rg.net> <44h3ak$p3j@newshost.lanl.gov> Reply-To: ThadSmith@acm.org NNTP-Posting-Host: 199.117.27.22