mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-03-09 15:50:02 +00:00
Revise the pow(1,inf) IEEE feature test to defeat clever compilers (#184)
Compilers like GCC are capable of optimizing away calls like pow(1,inf), which caused the IEEE compliance feature test within libast to incorrectly succeed on platforms with non-IEEE behavior. This is arguably a bug within GCC, as floating point optimizations should never alter the behavior of code unless IEEE compliance is explicitly disabled via a flag like -ffast-math. Programs in which only some calls to pow are optimized away are liable to severely malfunction. Thanks to Martijn Dekker for pointing this issue out and the kind operators of polarhome.com for permitting me gratis use of their Unix systems. src/lib/libast/comp/omitted.c: - Add IEEE compliant functions that wrap powf, pow, and powl. src/lib/libast/features/float: - Look for powf, pow, and powl in the C library. - For compilers that do the right thing, like the native toolchains of Solaris and UnixWare, use lightweight macros to wrap the pow functions. - Use a volatile function pointer through which to access the C library's pow function in an attempt to defeat code optimization. - For these overzealous compilers, define pow to _ast_pow so that the same technique can be used within the above functions.
This commit is contained in:
parent
c2cb0eae19
commit
72968eaed6
4 changed files with 59 additions and 8 deletions
|
|
@ -1216,6 +1216,7 @@ make install
|
|||
exec - iffe ${IFFEFLAGS} -v -c "${CC} ${mam_cc_FLAGS} ${KSH_RELFLAGS} ${KSH_SHOPTFLAGS} ${CCFLAGS} ${LDFLAGS}" ref ${mam_cc_L+-L.} ${mam_cc_L+-L${INSTALLROOT}/lib} -I${PACKAGE_ast_INCLUDE} -I${INSTALLROOT}/include ${mam_libdll} ${mam_libcmd} ${mam_libast} ${mam_libm} ${mam_libnsl} : run features/math.sh ${PACKAGEROOT}/src/cmd/ksh93/data/math.tab
|
||||
make ${PACKAGE_ast_INCLUDE}/ast_standards.h implicit
|
||||
done ${PACKAGE_ast_INCLUDE}/ast_standards.h dontcare
|
||||
prev ${INSTALLROOT}/src/lib/libast/FEATURE/float implicit
|
||||
done FEATURE/math generated
|
||||
prev include/streval.h implicit
|
||||
prev FEATURE/options implicit
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue