Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!lll-winken!uunet!littlei!donk!ajw From: ajw@donk.UUCP (ajw) Newsgroups: comp.lang.c Subject: Usual arithmetic conversions Keywords: sizeof unsigned ouch Message-ID: <308@donk.UUCP> Date: 22 May 89 18:57:25 GMT Organization: DTE, Intel Corporation; Hillsboro, OR Lines: 17 Don't you just hate it when code that has been working for years suddenly goes bad on you? This took a few merry hours to find: if (buf_size - (used_so_far + this_record_size + trailer_size) >= 0) enough_room_left(); "trailer_size" is in fact #defined as an expression which deep in its bowels includes a 'sizeof'. My new compiler (quite properly, I have no doubt), treats 'sizeof' as unsigned, with the result that the entire expression in the 'if' statement becomes unsigned, and thus the condition is always true. Trivial, I know, but hey, it beats chundering on about summing pointers. -- Alan Waldock, just offering individual opinions while happening to work at Intel Corp, M/S HF2-37, 5200 NE Elam Young Pkwy, Hillsboro, Oregon 97124-6497 ajw@aus.hf.intel.com ...uunet!littlei!intelhf!aus!ajw "Live malloc or die"