Xref: utzoo comp.lang.c:34574 comp.unix.xenix.sco:974 Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!ut-emx!ccwf.cc.utexas.edu!jon From: jon@ccwf.cc.utexas.edu (Jon Boede) Newsgroups: comp.lang.c,comp.unix.xenix.sco Subject: '386 XENIX "cc -Ox" optimization bug Summary: cc -Ox (cc -Oal) produces incorrect code with some loops Keywords: -Ox Message-ID: <40991@ut-emx.uucp> Date: 7 Dec 90 22:22:13 GMT Sender: news@ut-emx.uucp Reply-To: jon@ccwf.cc.utexas.edu (Jon Boede) Followup-To: comp.lang.c Organization: The University, People's Repulic of Austin, Texas Lines: 36 Originator: jon@doc.cc.utexas.edu Hopefully I'm posting old news... but I found a rather insidious bug in cc version 1.6. It seems that if you use the -Oa "ignore aliasing" option with the -Ol "enable loop optimizations" option, it starts thinking deciding that more things are loop invariants than really are! The seductively named -Ox "max. optimization" option implies -Oal. Try: cc x.c; a.out; cc -Ox x.c; a.out; cc -Oal x.c; a.out ----- cut here -- x.c main() { int value; value = 1; printf("1. value is %d\n",value); do { printf("2. value is %d\n",value); puts(value ? "works ok" : "your compiler is broke"); value = 0; } while (false()); } false() { return(0); } ----- ereh tuc It's a little bothersome to turn on "max. optimization" and have your code stop working! ;-) Jon -- Jon Boede jon@bodedo.ucm.org ...!{the-world}!uunet!cs.utexas.edu!bodedo!jon 7117 Wood Hollow #1013, People's Republic of Austin, TX 78731 +1 512 346-3142