side effects inside sizeof

Alain Williams addw at root44.UUCP
Thu Jun 28 12:30:14 AEST 1984


<<<<<To be eaten by mailers>>>>>
Henry Spencer @ U of Toronto Zoology produced the following abomination:
main(){
	int x = 1;

	printf("%u\n", sizeof(x++));
	printf("%d\n", x);
}

He grumbles that the second printf produces a result of "1", & comments:
>> But nowhere in K&R is there anything that would
>> permit this wanton disregard of side effects,
But there is "nowhere in K&R is there anything that would" suggest that
the compilers are to be proof against all idiots. If one tries hard enough
it is possible to find pathological cases that break almost anything. Indulging
in such exercises is something that I enjoyed as an undergraduate, but have
since grown out of. I now try & USE the tools that I have.
	Alain Williams,
	Root Computers Ltd, London.
	{ENGLAND}!hirst1!root44!addw
	edai!root44!rootis!addw
	ukc!root44!addw



More information about the Comp.lang.c mailing list