Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ncar!gatech!mcnc!rti!trt From: trt@rti.UUCP (Thomas Truscott) Newsgroups: comp.sys.hp Subject: +O2 common-subexpression bug Message-ID: <3091@rti.UUCP> Date: 28 Jul 89 20:19:46 GMT Distribution: comp Organization: Research Triangle Institute, RTP, NC Lines: 24 Under HP-UX 6.5, the following program gives different answers when compiled with and without "-O" (a.k.a. "+O2"). [Apologies if this has been mentioned before, I do not follow this group closely. Surely this has been discovered and fixed by now!] Tom Truscott main() { register char *s; register int a, b; s = "\1\2\3\4"; a = (s[0] + s[1]); s += 2; b = (s[0] + s[1]); printf("%d %d\n", a, b); a = s[1]; s--; b = s[1]; printf("%d %d\n", a, b); }