Un-alignment in structures

Henry Spencer henry at utzoo.UUCP
Wed Apr 3 04:03:17 AEST 1985


> Even on machines that "can't do" unaligned integers, this program
> will probably run without "error" and will give some garbage for
> output.  The point is that C programs can stuff any value whatsoever 
> into pointers.  After all, what's to stop them?  Unless you violate
> hardware bounds, you will usually get something.  At worst, the
> low-order bits will be ignored, and you'll get one of the "adjacent"
> aligned words.  

Wrong.  On most machines that don't support unaligned integers, you
will get a signal and a core dump.

> ...After all, what does it gain a man
> to save a millisecond of his computer's time if he loses an hour
> of his own time thereby?

Sometimes it saves his successor from spending many hours figuring out
how to get that millisecond out.  Yes, Virginia, some programs do have
to run fast, and few are the worse for a speed improvement.
-- 
				Henry Spencer @ U of Toronto Zoology
				{allegra,ihnp4,linus,decvax}!utzoo!henry



More information about the Comp.lang.c mailing list