John Fine schrieb: > The general concept of optimizations is to preserve the answer while > reducing the time needed to compute the answer. There are some cases in > which an optimization fails to preserve the answer, but those usually > occur in complex situations where the designer of the optimization had > no practical way to avoid the difference. > > As you noted c-(c-a) is routinely different from a. Anyone designing > optimizations would understand that. So making that optimization would > violate the general principle of optimization. I'm not quite sure about this claim. What if the c-(c-a) appears as the result of some optimization of a more complex expression? If someone writes this statement there is usually a reason for doing this. But I'm not sure if this can be distinguished from the case where it is an optimized version of a more complex expression. > I don't know of any gcc option that might turn on that questionable > "optimization". I doubt that there is one, but I'm not certain there > isn't. Reading the documentation of -ffast-math I would have assumed it to do exactly that `-ffast-math' Sets `-fno-math-errno', `-funsafe-math-optimizations', `-fno-trapping-math', `-ffinite-math-only', `-fno-rounding-math', `-fno-signaling-nans' and `fcx-limited-range'. This option causes the preprocessor macro `__FAST_MATH__' to be defined. This option should never be turned on by any `-O' option since it can result in incorrect output for programs which depend on an exact implementation of IEEE or ISO rules/specifications for math functions. You could imagine a (stupid) test for coming close to overflow f = f + 1.0 - 1.0. This isn't optimized away with O3 but -ffinite-math-only removes it. So it seems to be connected to reassociation with floats. This seems to be introduced at least into GCC 4.3.0 (see my answer to Alexander Monakov). Cheers, Christian -- Christian Keil /"\ Institute for Reliable Computing \ / ASCII Ribbon Campaign Hamburg University of Technology X against HTML email & vCards mail:c.keil@xxxxxxxxxxxxx / \