This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Pointer type problem (plain C on i386)


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~


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]