is this broken or what?

David desJardins desj at idacrd.UUCP
Wed Jan 24 17:04:51 AEST 1990


>From article <1482 at mdbs.UUCP>, by wsmith at mdbs.UUCP (Bill Smith):
> 	unsigned u = 0;
> 	if (u-- < 4)

> 	unsigned u = 0;
> 	if(--u < 3) ....

   Can someone closely familiar with the ANSI standard tell us what
are the allowable things which might happen when one decrements the
unsigned value 0?  Certainly there are many compilers which will
assign a large positive value to the result, and so presumably the
standard allows this.  Can an ANSI-compliant compiler:

(1) Assign some other new value (e.g., zero)?
(2) Generate a run-time error?

I would presume that both of these are legal responses, but I wouldn't
mind hearing that from someone with more direct knowledge.

   As for the example code, I don't have any sympathy at all, although
I do grudgingly admit that that particular optimization probably isn't
a good idea.

   -- David desJardins



More information about the Comp.lang.c mailing list