🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #606

Assignment compatibility

#606
From: John Bowler
Date: Wed, 20 Sep 1989 17:02
41 lines
1676 bytes
As far as I can see, in the fragment:-

{
	const void **cptr;
	void **ptr;

	...
	cptr = ptr;
	...
}

The assignment is non-conforming, because a constraint on the
assignment operator is violated; section 3.3.16.1:-

 ``One of the following shall hold:

   ...
   o 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.''

and (section 3.5.3):-

 ``For two qualified types to be compatible, both shall have the identically
   qualified version of a compatible type''

so ``const void *'' is NOT compatible with ``void *'' (well, it isn't totally
clear - ``void *'' is not qualified...) and therefore an expression of the
form:-

	(const void **) = (void **)

is not allowed.  Is this correct?  If so, why; I can assign a (void *) to
a (const void *), but not a (void **) to a (const void **), despite the
fact that I can do nothing with a (const void **) which I could not do
with a (void **)!  In particular, the values which I can assign to
*cptr (type (const void **)) are a subset of the values which I can
assign to *ptr (void **).  (Anything which I can assign to *cptr, I can
also validly assign to *ptr).

John Bowler (jbowler@acorn.co.uk)
Technical Details
Message-ID: <838@acorn.co.uk>
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!uunet!mcsun!ukc!acorn!john

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!uunet!mcsun!ukc!acorn!john
From: john@acorn.co.uk (John Bowler)
Newsgroups: comp.std.c
Subject: Assignment compatibility
Message-ID: <838@acorn.co.uk>
Date: 20 Sep 89 17:02:43 GMT
Reply-To: john@acorn.UUCP ()
Organization: Acorn Computers Ltd, Cambridge, UK
Lines: 41