* RE: <optimized out>
[not found] <616BE6A276E3714788D2AC35C40CD18D7D2584@whale.softwire.co.uk>
@ 2002-09-02 5:38 ` Rupert Wood
2002-09-02 5:50 ` Der Herr Hofrat
0 siblings, 1 reply; 3+ messages in thread
From: Rupert Wood @ 2002-09-02 5:38 UTC (permalink / raw)
To: 'Der Herr Hofrat'; +Cc: gcc-help
Der Herr Hofrat wrote:
> then gcc with -O2 seems to directly push 3 on the stack and call
> printf and never used a local variable so I can't access it in the
> debuger. Is there any simply way of preventing this other than doing
> stupid things like introducing some useless statements to force a
> local variable but without turning of -O2 for the entire file ???
Not sure why you'd want to do this unless you've got problems with the
optimized code; you could always debug at -O0.
However, declaring the variable a 'volatile' ought to do what you want.
One of the '-f' switches might prevent this optimization globally if
you'd prefer but at first glance I can't see which one it might be.
Rup.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: <optimized out>
2002-09-02 5:38 ` <optimized out> Rupert Wood
@ 2002-09-02 5:50 ` Der Herr Hofrat
0 siblings, 0 replies; 3+ messages in thread
From: Der Herr Hofrat @ 2002-09-02 5:50 UTC (permalink / raw)
To: Rupert Wood; +Cc: 'Der Herr Hofrat', gcc-help
> Der Herr Hofrat wrote:
>
> > then gcc with -O2 seems to directly push 3 on the stack and call
> > printf and never used a local variable so I can't access it in the
> > debuger. Is there any simply way of preventing this other than doing
> > stupid things like introducing some useless statements to force a
> > local variable but without turning of -O2 for the entire file ???
>
> Not sure why you'd want to do this unless you've got problems with the
> optimized code; you could always debug at -O0.
>
> However, declaring the variable a 'volatile' ought to do what you want.
yup - thanks volatile int i; did it.
thx !
hofrat
^ permalink raw reply [flat|nested] 3+ messages in thread
* <optimized out>
@ 2002-09-02 5:16 Der Herr Hofrat
0 siblings, 0 replies; 3+ messages in thread
From: Der Herr Hofrat @ 2002-09-02 5:16 UTC (permalink / raw)
To: gcc-help
HI !
how can I prevent GCC from optimizing away a specific variable ?
lets say I have something trivial like
int i;
i=3;
printf("%d\n",i);
then gcc with -O2 seems to directly push 3 on the stack and call printf
and never used a local variable so I can't access it in the debuger. Is
there any simply way of preventing this other than doing stupid things like
introducing some useless statements to force a local variable but without
turning of -O2 for the entire file ???
hofrat
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2002-09-02 12:50 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <616BE6A276E3714788D2AC35C40CD18D7D2584@whale.softwire.co.uk>
2002-09-02 5:38 ` <optimized out> Rupert Wood
2002-09-02 5:50 ` Der Herr Hofrat
2002-09-02 5:16 Der Herr Hofrat
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).