>I tried compiling the sample I posted for Mark with the -O switch. It
>compiled without giving me an error, but the program actually RUNS
>without crashing! ANY of the "-O" switches seem to fix it!
-O just turns on optimization. The optimizer should NEVER change the
meaning of your program. If optimizing changes the behaviour of the
program in any way (except making it faster), then something is broken
somewhere.
In your stat_a.c example, the optimizer in my compiler (arm-linux-gcc
(GCC) 3.3.4) does not call stat(), even though that is what you wrote
in your program. It replaces it with a call to __xstat(). Presumably,
__xstat() is a functional equivalent to stat() that the optimizer knows
it can safely use.
In this example, the optimizer makes it work, but only because you got
lucky and the bug got swept under the rug.
If you would like to see the machine code for a particular source
file, add -S to the compiler options and look at the .s file created.
Sometimes it can be very instructive, even if you aren't real familiar
with the instruction set.
Mark S.
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/ts-7000/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/ts-7000/join
(Yahoo! ID required)
<*> To change settings via email:
<*> To unsubscribe from this group, send an email to:
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
|