qualifications in prototypes (was Re: Problems with IBM RS6000 C compiler)

Karl Heuer karl at haddock.ima.isc.com
Wed Aug 8 00:17:17 AEST 1990


In article <1896 at tkou02.enet.dec.com> diamond at tkou02.enet.dec.com (diamond at tkovoa) writes:
>[Can you pass an unqualified `char *' to a function whose prototype declares
>a parameter of type `char const *'?]
>
>Section 3.3.2.2:  "Each argument shall have a type such that its value
>may be assigned to an object with the unqualified version of the type of
>its corresponding parameter."

I agree the the question is equivalent to that of simple assignment.

>I interpret that the "unqualified version" of a type only removes the
>top-level qualifiers.  [3.1.2.5 supports this.]

I'm willing to grant that, too.

>The Rationale for section 3.1.4 further emphasizes the matter of what
>cannot be assigned to what, which seems to support my opinion on the
>function arguments.

It mentions only the assignment *from* qualified *to* unqualified.  Nobody
disputes that this is illegal without a cast.

>Section 3.2.2.3 specifies what pointers may be converted and still compare
>equal.  It does not specify that conversions are applied automatically
>without a cast.  Sorry, but I believe it is irrelevant to the topic.

Okay, then, let's try 3.3.16.1 Simple Assignment: "Constraints: One of the
following shall hold: ... both operands are pointers to qualified or
unqualified versions of compatible types, and the type pointed to by the left
has all the qualifiers of the type pointed to by the right."

Karl W. Z. Heuer (karl at kelp.ima.isc.com or ima!kelp!karl), The Walking Lint



More information about the Comp.lang.c mailing list