Path: utzoo!dciem!array!rob From: rob@array.UUCP (Rob Marchand) Newsgroups: comp.unix.programmer Subject: Re: Optimizing out unreferenced variables Message-ID: <1900@array.UUCP> Date: 8 May 91 15:19:32 GMT References: <608@elroy> <1475@ecicrl.ocunix.on.ca> Organization: Array Systems Computing, Inc., Toronto, Ontario, CANADA Lines: 33 In article <608@elroy> davidk@dsinet (David Karr) writes: |I have been hearing about a tendency for certain Unix optimizing C compilers |to deal harshly with static variables declared in C modules that are not |referenced in that module. In other words, it will delete those variables |from the object file. A controversial example would be variables declared |in each module to hold RCS or SCCS information. Often these variables will |be declared as static, and only used by certain utilities to parse out the |version numbers from an executable binary. I have seen this as well. |I was told that the C compiler on AIX has this particular "affliction". Is |this a general feature of optimizing C compilers, and will more compilers |be adding this "feature" as time goes on, or is the AIX compiler a fluke? I |heard a mention that the HP 700 compiler would be doing this in the future. I believe that an older version of the VMS C compiler would optimize out static variables that were not used. The case with RCS that you mention is in fact the way I found this out. I don't know about newer versions of the compiler... More an inconvenience than anything, but in some cases it is sure handy to be able to identify the contents of the binary with certainty. I guess the question is whether you also patch the RCS $id$ string when you do binary patches to the file :-) Kidding! Just kidding! Cheers! Rob Marchand -- Rob Marchand UUCP : uunet!attcan!lsuc!array!rob Array Systems Computing ARPA : rob%array.UUCP@uunet.UU.NET 401 Magnetic Drive, Unit 24 Phone : +1(416)736-0900 Fax: (416)736-4715 Downsview, Ont CANADA M3J 3H9 Telex : 063666 (CNCP EOS TOR) .TO 21:ARY001