From owner-cvs-src@FreeBSD.ORG Wed Jul 7 06:28:49 2004 Return-Path: Delivered-To: cvs-src@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id C77C516A4CE; Wed, 7 Jul 2004 06:28:49 +0000 (GMT) Received: from mailout2.pacific.net.au (mailout2.pacific.net.au [61.8.0.85]) by mx1.FreeBSD.org (Postfix) with ESMTP id 474DC43D4C; Wed, 7 Jul 2004 06:28:49 +0000 (GMT) (envelope-from bde@zeta.org.au) Received: from mailproxy1.pacific.net.au (mailproxy1.pacific.net.au [61.8.0.86])i676SlaR017925; Wed, 7 Jul 2004 16:28:47 +1000 Received: from gamplex.bde.org (katana.zip.com.au [61.8.7.246]) i676Siao019743; Wed, 7 Jul 2004 16:28:45 +1000 Date: Wed, 7 Jul 2004 16:28:44 +1000 (EST) From: Bruce Evans X-X-Sender: bde@gamplex.bde.org To: David Schultz In-Reply-To: <20040707022547.GA52027@VARK.homeunix.com> Message-ID: <20040707161210.L3048@gamplex.bde.org> References: <200407060922.i669MJua014841@repoman.freebsd.org> <20040707022547.GA52027@VARK.homeunix.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII cc: cvs-src@freebsd.org cc: src-committers@freebsd.org cc: cvs-all@freebsd.org cc: Dag-Erling Smorgrav Subject: Re: cvs commit: src/lib/libalias alias.c X-BeenThere: cvs-src@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: CVS commit messages for the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 Jul 2004 06:28:50 -0000 On Tue, 6 Jul 2004, David Schultz wrote: > On Tue, Jul 06, 2004, Dag-Erling Smorgrav wrote: > > Rewrite twowords() to access its argument through a char pointer and not > > a short pointer. The previous implementation seems to be in a gray zone > > of the C standard, and GCC generates incorrect code for it at -O2 or > > higher on some platforms. > > I don't think this is even a gray zone---the C standard > specifically disallows aliasing of pointers to different types > unless one of the types is a 'char *'. It's grey in the gcc standard. If there were a gcc standard, then it should support accesses via pointers of different types if there are no hardware [1] alignment problems, since Normal C programs do this, but since there is no gcc standard no one really knows what gcc supports. The C standard actually specifically allows aliasing of pointers to different types if the access is through a pointer to a character type. The character type also needs to be unsigned char to avoid the possibility of trap representations. [1] gcc supports the packig and alignment attributes, so it must support pointers to misaligned objects, at least if it silently discards attributes when taking addresses like it does now. Bruce