From owner-cvs-all Wed Jul 4 14:42: 9 2001 Delivered-To: cvs-all@freebsd.org Received: from bremen.shuttle.de (bremen.shuttle.de [194.95.249.251]) by hub.freebsd.org (Postfix) with ESMTP id DC61E37B401; Wed, 4 Jul 2001 14:42:00 -0700 (PDT) (envelope-from schweikh@schweikhardt.net) Received: by bremen.shuttle.de (Postfix, from userid 10) id 6ADBC17D60; Wed, 4 Jul 2001 23:41:59 +0200 (CEST) Received: (from schweikh@localhost) by hal9000.schweikhardt.net (8.11.4/8.11.3) id f64JQPP06991; Wed, 4 Jul 2001 21:26:25 +0200 (CEST) (envelope-from schweikh) Date: Wed, 4 Jul 2001 21:26:24 +0200 From: Jens Schweikhardt To: Joerg Wunsch Cc: cvs-committers@FreeBSD.org, cvs-all@FreeBSD.org Subject: Re: cvs commit: src/sys/sys bio.h Message-ID: <20010704212624.A1812@schweikhardt.net> References: <20010703193214.A3398@uriah.heep.sax.de> <200107032051.f63KpIm01502@mass.dis.org> <20010703233321.C3398@uriah.heep.sax.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <20010703233321.C3398@uriah.heep.sax.de>; from j@uriah.heep.sax.de on Tue, Jul 03, 2001 at 11:33:21PM +0200 Sender: owner-cvs-all@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Tue, Jul 03, 2001 at 11:33:21PM +0200, Joerg Wunsch wrote: # As Mike Smith wrote: ... # > > Also, using a void * would have complicated matters pretty much. It's # > > invalid to abuse a void * as an int # > # > Er, no it's not. # > # > void *foo; # > int bar; # > # > bar = (int)(uintptr_t)foo; # > # > foo = (void *)(uintptr_t)bar; # # I think that's wrong C. AFAIR, an arbitrary /pointer/ is allowed to # be cast to a void *, and then cast back to just that arbitrary s/cast/assigned to/g void pointers exist to fill^Wopen a gap in the type system. Casting pointers to and from void* is a silly thing to do outside variable arg lists (and only done by the C++ infected where it is rquired :-) # pointer, and this is the only valid operation on void pointers. # Casting a scaler type to a void * and back is not a valid operation. # (First, the machine might have a different bit length for pointers and # scalars, and IMHO it's even possible that a machine has an entirely # different address space for pointers and scalars, something like the # IA32 architecture has different address spaces for memory and IO # pointers.) # # Someone with a better standards background than me might comment on # this. For the time being, here's the reference to K&R2 (p 199): # # ``A6.8 Pointers to Void # # Any pointer to an object may be converted to type void * without loss # of information. If the result is converted back to the original # pointer type, the original pointer is recovered. [...]'' # # So only pointers are allowed here. In ISO C (89 and 99) assignment between pointers and integers without a cast requires a diagnostic (see the constraints in "simple assignment".) However, implementations are free to DTRT upon encountering things like char *p = (char *)0xf00baa; and gcc certainly has done what you would expect ever since. It might even be documented to work, if in the source... Regards, Jens -- Jens Schweikhardt http://www.schweikhardt.net/ SIGSIG -- signature too long (core dumped) To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe cvs-all" in the body of the message