Path: utzoo!attcan!uunet!contex!chris From: chris@contex.UUCP (Chris Anderson) Newsgroups: comp.unix.ultrix Subject: Warning! Compiler Bug (DecSt.3100) Summary: Unsigned compares + invalid optimization Keywords: XNS Message-ID: <473@contex.UUCP> Date: 21 Nov 89 19:42:20 GMT References: <458@tron.UUCP> Organization: Xyvision Design Systems, Wakefield MA Lines: 16 The following program, when compiled on the DecStation 3100, produces d=0, when it should be d=1: unsigned a = 2, d; int b = 1, c = 1; d = (c >= (b - a + 1)); What happens is that the whole expression is promoted to unsigned as expected, but then the comparison is changed to ">" and the +1 operation is "optimized" out. (Note, this happens even without -O). Voila! Bad code. Beware of unsigned IFs with +1 in them somewhere... Chris Anderson (contex!chris@uunet.uu.net) Xyvision, Inc.