Compiler and (a-b)*(a-b)?

Compiler and (a-b)*(a-b)?

tmp = (a - b) * (a - b);

Does the compiler compute (a - b) twice?

2 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

If either a or b are expressions with side effects, they will be evaluated twice. Otherwise, no, not unless you have turned off all optimization.

Leave a Comment

Please sign in to add a comment. Not a member? Join today