I tested this code with "g++ -S -O1", and checked the generated assembly code. I found G++ dropped the statement "e = d * 1" completely, since "e" is a local variable and is assigned a value, but never used later. If "e" is used later, G++ would optimize "e = d * 1 " as "e = d". On 9/29/07, Peng Yu <pengyu.ut@xxxxxxxxx> wrote: > Hi, > > Can anybody let me know whether g++ will optimize for the following case? > > void f(double d) > double e; > ..... do something > > e = d * 1.;// will this be optimized as e = d; > } > > Thanks, > Peng >