What breaks? (was Re: 64 bit longs?)

Walter Bright bright at nazgul.UUCP
Sat Jan 19 18:22:19 AEST 1991


In article <54379 at eerie.acsu.Buffalo.EDU> chu at acsu.buffalo.edu (john c chu) writes:
/In article <1991Jan13.220958.16568 at zoo.toronto.edu> henry at zoo.toronto.edu (Henry Spencer) writes:
/>It is intuitively appealing, but I would be surprised to see anyone
/>implementing it:  it would break far too much badly-written software.
/Can someone please tell me what would break under that model and why?
/It's not that I don't believe it, or that I want to write code that
/will break. It's that I want to avoid making the unwarranted
/assumptions that would lead to my code breaking.

Code that will break:
	char *p;
	unsigned long x;
	...
	/* Read 4 bytes out of buffer */
	x = *(unsigned long*)p;  /* assume bytes are in correct order */
Also:
	x >>= 24;
	/* Now assume that x < 256 */
Also:
	x &= 0xFFFFFFFE;	/* clear bit 0 */



More information about the Comp.lang.c mailing list