Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!usc!zaphod.mps.ohio-state.edu!sol.ctr.columbia.edu!ira.uka.de!smurf!urlichs From: urlichs@smurf.sub.org (Matthias Urlichs) Newsgroups: comp.sys.mac.programmer Subject: Re: compiler-generated code quality (Re: Pascal deficiency?) Message-ID: Date: 20 Dec 90 12:20:17 GMT References: <1990Dec17.233507.16372@phri.nyu.edu> <9611@ncar.ucar.edu> Organization: University of Karlsruhe, FRG Lines: 26 In comp.sys.mac.programmer, article <9611@ncar.ucar.edu>, hpoppe@ncar.ucar.edu (Herb Poppe) writes: < In article urlichs@smurf.sub.org (Matthias < Urlichs) writes: < > a () { int x; x = 1; x = x + 1; xyzzy(x); } < > < > gcc (which, for the purposes of this discussion, certainly counts as a real < > compiler) will push the value 2 onto the stack without bothering to create < > and increment a variable. < < If that is the case, if I were to "debug" this routine with a symbolic < debugger, what would it show as the value of "x"? < Nothing -- because that variable is optimized out, the symbol "x" is undefined in that context. (I just checked.) "Normal" C compilers don't allow you to use both symbols and optimizations at the same time... doing this with gcc can lead to some interesting effects, especially when it starts unrolling small loops, partially combining case statements, or optimizing function calls out of your program (you can tell gcc that a procedure doesn't have side effects). -- Matthias Urlichs -- urlichs@smurf.sub.org -- urlichs@smurf.ira.uka.de /(o\ Humboldtstrasse 7 - 7500 Karlsruhe 1 - FRG -- +49+721+621127(0700-2330) \o)/