Path: utzoo!attcan!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!elroy.jpl.nasa.gov!usc!apple!apple.com!chewy From: chewy@apple.com (Paul Snively) Newsgroups: comp.sys.mac.programmer Subject: Re: compiler-generated code quality (Re: Pascal deficiency?) Message-ID: <11604@goofy.Apple.COM> Date: 20 Dec 90 19:40:57 GMT References: <9611@ncar.ucar.edu> Sender: usenet@Apple.COM Organization: Apple Computer, Inc. Lines: 32 In article <9611@ncar.ucar.edu> hpoppe@ncar.ucar.edu (Herb Poppe) writes: > > 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"? From "Using and Porting GNU CC," page 14, I quote: "Unlike most other C compilers, GNU CC allows you to use '-g' with '-O'. The shortcuts taken by optimized code may occassionally produce surprising results: some variables you declared may not exist at all..." __________________________________________________________________________ Paul Snively Macintosh Developer Technical Support Apple Computer, Inc. chewy@apple.com Just because I work for Apple Computer, Inc. doesn't mean that I believe what they believe, or vice-versa. __________________________________________________________________________