Sujet : Re: So You Think You Can Const?
De : jameskuyper (at) *nospam* alumni.caltech.edu (James Kuyper)
Groupes : comp.lang.cDate : 12. Jan 2025, 01:29:55
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vlv2e3$rcjb$1@dont-email.me>
References : 1 2 3 4 5 6 7 8 9
User-Agent : Mozilla Thunderbird
On 1/11/25 11:21, Julio Di Egidio wrote:
...
In fact, along that line, I could see one might insist that "strictly
speaking, it should be `void free(void *const p)
You should keep in mind that the 'const' in that declaration is
meaningless. Normally,
"If the function is defined with a type that is not compatible with the
type (of the expression) pointed to by the expression that denotes the
called function, the behavior is undefined." (6.5.2.2p7)
However,
"For two function types to be compatible ... 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." (6.7.6.3p14)
Therefore, it's entirely permissible for a function's definition to have
parameters with different qualifiers than the ones specified in the
function declaration. And the ones specified in the function declaration
have no effect on the validity or meaning of any expression using that
declaration. Such qualifiers only have meaning within the function's
definition itself.