🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #16

Re: Questions about conversions of pointer-to-qualified types.

#16
From: Larry Jones
Date: Tue, 27 Oct 1992 16:27
61 lines
2569 bytes
In article <1992Oct27.073329.6679@netcom.com>, rfg@netcom.com (Ronald F. Guilmette) writes:
< [rearranged somewhat]
< I'm having a hard time understanding just what the standard says (let
< alone what it means) when it comes to implicit conversions of one
< pointer type to another.
< 
< Now section 3.2.2.3 seems pretty clear, but I know that there are other
< bits of relevant stuff hiding elsewhere in the standard (but I'm not
< sure where anymore).  I'm pretty sure that the phrase "a qualified or
< unqualified version of void" is lurking in there somewhere... and it
< may relate to this "conversions" issue... but where is it that I saw
< that?

3.2 only specifies the results of a conversion.  The conversions it
describes are NOT applied automatically, the description of each
operator in 3.3 says which conversions to apply.

< Here is an example of what I mean...
< 		void *vp;
< 		char const *ccp;
< 
< 			vp = ccp;
< I'm fairly sure that this assignment is legal (even though I think it
< shouldn't have been permitted by x3j11).

Nope, it violates the constraint in 3.3.16.1 (Simple Assignment) which
specifies the allowable arguments.  It comes closest to meeting the one
that says:

	one operand is a pointer to an object or incomplete type and the
	other is a pointer to a qualified or unqualified version of
	void, and the type pointed to by the left has all the qualifiers
	of the type pointed to by the right

but it violates the last clause since the right points to a const
qualified type and the left does not.

< Now, what about this:
< 		const void *cvp;
< 		char *cp;
< 
< 			cp = cvp;
< 
< Is *that* assignment permitted?

Nope, same problem.

< (Note that "void" comes up a lot in the standard in different contexts.
< For example, 3.3.4 seems to say that:
< 		int i;
< 
< 			... (const void) i;
< .... is illegal!

Yes, it is exactly equivalent to "(void) i"; since the result of a cast
is not an lvalue, qualifiers are meaningless.
----
Larry Jones, SDRC, 2000 Eastman Dr., Milford, OH  45150-2789  513-576-2070
larry.jones@sdrc.com  or  ...uunet!sdrc!larry.jones
He just doesn't want to face up to the fact that I'll be
the life of every party. -- Calvin
Technical Details
Message-ID: <2173@sdrc.COM>
Path: arc1-ca.pugleaf.net!sparky!uunet!sdrc!thor!scjones
References: <1992Oct27.073329.6679@netcom.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!sdrc!thor!scjones
From: scjones@thor.sdrc.com (Larry Jones)
Newsgroups: comp.std.c
Subject: Re: Questions about conversions of pointer-to-qualified types.
Message-ID: <2173@sdrc.COM>
Date: 27 Oct 92 16:27:35 GMT
References: <1992Oct27.073329.6679@netcom.com>
Sender: news@sdrc.COM
Lines: 61