Path: utzoo!mnetor!tmsoft!torsqnt!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!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: compiler-generated code quality (Re: Pascal deficiency?) Message-ID: Date: 18 Dec 90 23:31:03 GMT References: <1990Dec17.160242.5095@phri.nyu.edu> <1990Dec17.172613.7941@cs.umn.edu> <1990Dec17.233507.16372@phri.nyu.edu> Organization: University of Karlsruhe, FRG Lines: 20 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. -- Matthias Urlichs -- urlichs@smurf.sub.org -- urlichs@smurf.ira.uka.de /(o\ Humboldtstrasse 7 - 7500 Karlsruhe 1 - FRG -- +49+721+621127(0700-2330) \o)/