lua-users home
lua-l archive

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



I was struck by this, it's still partly a mystery but hardly my imagination. :)

If you use Lua mathlib with -ffast-math, this shall effect you.

    Lua 5.1 (work4)  Copyright (C) 1994-2004 Tecgraf, PUC-Rio
    > print( math.floor(0.5) )
    0.5
    > print( math.ceil(0.7) )
    0.7

-ak


Edelleenlähetetty viesti alkaa:

Lähettäjä: Asko Kauppi <asko.kauppi@sci.fi>
Päiväys: 8. kesäkuuta 2005 11.32.02 GMT+03:00
Vastaanottaja: fink-devel@lists.sourceforge.net
Aihe: XCode 2.1 and -ffast-math



Has anyone else experienced this weird bug, occurring after upgrade to the new XCode 2.1:

System:
    OS X Tiger (10.4.1)
    iMac G4 700MHz
XCode 2.1 (actually, using gcc from command line, but.. does it matter)

If -ffast-math is given to gcc, it #defines floor[f] and ceil[f] to __fastmath_floor[f] and so. These are inline functions that treat -0.0 in a non-standard way. So what..

For me, in some places, floorf(0.7)==0.7 ! That's no use. Weird thing is, that this is not consistent, some places work, others don't. Possibly some variable assignment/code generation/whatever weirdness?

Anyway, I did not have this (same code) before running XCode 2.1, so clearly there's something wrong.

If some of you would have XCode 2.0, please send /usr/include/ architecture/ppc/math.h so I can compare them. It may be the function hasn't changed, but gcc code generation has, though.

First aid: just stop using '-ffast-math' or #undef the macros it defines. Regular libm functions will be used, and they work. :)

-ak