Date: Wed, 7 Jul 2004 16:28:44 +1000 (EST) From: Bruce Evans <bde@zeta.org.au> To: David Schultz <das@freebsd.org> Cc: Dag-Erling Smorgrav <des@freebsd.org> Subject: Re: cvs commit: src/lib/libalias alias.c Message-ID: <20040707161210.L3048@gamplex.bde.org> In-Reply-To: <20040707022547.GA52027@VARK.homeunix.com> References: <200407060922.i669MJua014841@repoman.freebsd.org> <20040707022547.GA52027@VARK.homeunix.com>
index | next in thread | previous in thread | raw e-mail
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. Brucehome | help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040707161210.L3048>
