lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

Tony Finch wrote:
> It looks like gcc on the powerpc isn't implementing IEEE 754 rounding
> modes correctly or consistently with -O2. If I recompile Lua without
> optimisation then the negative zeroes go away.

Nope, your program doesn't use the FENV_ACCESS pragma, so the
C compiler is free to fold the FP constants using the default
rounding mode. Since -O2 enables constant folding, you may get
different output if the rounding mode differs at runtime.

Note that FENV_ACCESS is implemented only in GCC 4.5 or higher.
But you can turn it on globally in earlier versions with
-frounding-math (the default is off).

Also note that your finding is unrelated to the problem at hand
(no constant folding, no change of rounding mode). There's some
prior evidence of buggy or miscompiled floor/ceil for OSX/PPC:

So the toolchain of the original poster is probably too old and
broken in this regard. Occam's Razor strikes again.