Path: utzoo!attcan!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!elroy.jpl.nasa.gov!ncar!ncar.ucar.edu!hpoppe From: hpoppe@ncar.ucar.edu (Herb Poppe) Newsgroups: comp.sys.mac.programmer Subject: Re: compiler-generated code quality (Re: Pascal deficiency?) Message-ID: <9611@ncar.ucar.edu> Date: 19 Dec 90 16:25:05 GMT Sender: news@ncar.ucar.edu Organization: National Center for Atmospheric Research Lines: 31 References:<1990Dec17.160242.5095@phri.nyu.edu> <1990Dec17.172613.7941@cs.umn.edu> <1990Dec17.233507.16372@phri.nyu.edu> In article urlichs@smurf.sub.org (Matthias Urlichs) writes: > In comp.sys.mac.programmer, article <1990Dec17.233507.16372@phri.nyu.edu>, > roy@phri.nyu.edu (Roy Smith) writes: > < > < a () { int x; x = 1; x = x + 1; } > < b () { int x; x = 1; x++; } > < > < [ table deleted ] > > Note that a real compiler will generate _no_ code for the above procedures > (other than procedure entry/exit stuff), because the value isn't used > anywhere. Similarly, if you try to fix that by saying > 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"? Herb Poppe hpoppe@ncar.ucar.edu NCAR (303) 497-1296 1850 Table Mesa Dr. Boulder, CO 80307-3000