Funny bugs in some C compilers - (nf)

edler at cmcl2.UUCP edler at cmcl2.UUCP
Thu Sep 15 06:55:09 AEST 1983


#R:wateng:-27500:cmcl2:15400004:000:711
cmcl2!edler    Sep 14 16:54:00 1983

The following suggestion has been made:

	Permit comparison of two structures of the same tag or typedef
	for [in]equality only.  If the structure template involved contains
	no holes, compare the structures using a block-compare instruction
	(if available).  If there ARE holes, the result is the && conjunction
	[|| disjunction] of comparisons for [in]equality of constituent blocks
	that have no holes.
	
This won't work for structures containing unions of different-sized
components.  For example, I don't see how any C compiler can compare
two instances of the following structure:

	struct a {
		int b;
		union {
			char c;
			long d;
		} e;
	};

	Jan Edler	cmcl2!edler	(New York University)
			edler at nyu



More information about the Comp.lang.c mailing list