From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1164f8,d97e2c0b2e1a318e,start X-Google-Attributes: gid1164f8,public From: jw@adasoft.ch (Jamie Watson) Subject: Digital Unix 3.2C optimizer bug? Date: 1996/01/31 Message-ID: #1/1 X-Deja-AN: 137506059 organization: Adasoft AG, Subingen, Switzerland reply-to: jw@adasoft.ch (Jamie Watson) newsgroups: comp.sys.dec It appears that I have also stumbled across a fairly nasty optimizer bug in my transition to Digital Unix 3.2C. I am porting some pretty old C code in our application. Why does it so often seem to be the sources that *you* didn't write that cause the problems? In this case, one of our programs contains the following: for (size = 0, sqlvars = (GetPutFlag == FETCHFLG ? f_desc->sqlvar : i_desc->sqlvar), i = (GetPutFlag == FETCHFLG ? f_desc->sqld : i_desc->sqld); i > 0; i--, sqlvars++) Now, this isn't the most wonderful C code in the world, but it certainly looks to me as if it is completely legal, given that all the variables are declared with the appropriate types and such. I'm not including the complete context here, because I'm not looking for someone to debug the program, I'm looking for (or hoping for) confirmation of a compiler bug. When this program is compiled, the value of "i" after the loop initialization is incorrect; in fact, what it contains is the same value that was assigned to "sqlvars". I have found that if I reverse the order of the second and third lines, the problem is solved and the program runs correctly. Also, if I simply turn off optimization when compiling this file, the problem is gone and the program runs. So, am I safe in assuming that this is a compiler bug? Has anyone ever seen or heard of such a bug in Digital Unix 3.2C? Even better, does anyone know if there is a patch available that fixes this problem? Thanks. jw