Subj : Re: Any help on why? To : borland.public.cpp.borlandcpp From : Stan DeGroff Date : Wed Jul 07 2004 02:56 pm BC++ V5.02 Copyright 1997 You've come up with exactly what I think was going on. I've seen other cases do the same. printf doesn't seem to invoke code that produces values that stick around beyond their non-printf use. When I look at the CPU screen I see that code is optimized. (Even though I have "no optimization" checked in the project->options screen. Some statements can't be used as break points as they have been optimized away as well.) Is there a way to insure optimization is not invoked? "Bob Gonder" wrote in message news:3d8ne01afvj3q4ph7s71lklv2ej45c90gl@4ax.com... > Stan DeGroff wrote: > > > for (i=0; i > xresult = double va_arg(arglist, double); > > result += xresult; > > printf("%d %X, %X\n", i, xresult, result); > > } > > That prints the > >variable "xresult" resulted in printing 0x0000. However the variable > >"result" printed ok. Any ideas why the compiler forgets xresult? > > I know this sounds weird, but try this. > > for (i=0; i xresult = double va_arg(arglist, double); > printf("%d %X, %X\n", i, xresult, result); > result += xresult; > } > > I think that because xresult isn't needed later, it is optimised away. > If xresult were global, or used later, it would be made "real". > (Apparantly, being inside a printf is being invisible.) > There's a bug in the optimizer. > > BTW, which compiler are you using? > > .