This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: Pointer type problem (plain C on i386)
- To: Balazs Takacs <s8513tak at hszk dot bme dot hu>
- Subject: Re: Pointer type problem (plain C on i386)
- From: Richard Henderson <rth at redhat dot com>
- Date: Sun, 25 Feb 2001 10:40:06 -0800
- Cc: gcc-bugs at gcc dot gnu dot org
- References: <Pine.GSO.4.21.0102191349510.22700-401000@ural2>
On Mon, Feb 19, 2001 at 02:46:47PM +0100, Balazs Takacs wrote:
> > #define DIO_HIWORD(x) ((unsigned short *) &(x))[1]
[...]
> > data = *buf++;
> > outw(DIO_LOWORD(data), iobase);
> > outw(DIO_HIWORD(data), iobase);
This code is incorrect. You've violated type aliasing rules.
And in this case, for no apparent reason -- you could just as
well have written
outw(data, iobase);
outw(data >> 16, iobase);
r~