numeric fdlibm

David Chase chaseaworld.std.com
Thu Aug 1 15:44:50 PDT 2002


I have done some work on fdlibm, though I did not spend any
time attempting to solve problems with pointer aliasing that
were not (at the time) causing me problems.  The problems I
ran into involved incorrect constant propagation of NaN and -0,
plus Microsoft's VC++ (several versions) mistakenly applied
the distributive law to FP arithmetic (this may have been fixed
in the compiler since then; someone from Microsoft did contact
me about this bug).

If it is necessary to solve the pointer aliasing problems, it
should be sufficient to simply make all the loads and stores
to memory accessed with cast pointers be volatile (all of them,
both the cast-pointer accesses, and the uncast accesses).  A
compiler that elides or reorders volatile loads and stores is
incorrect.  Note that the code remains officially "unportable"
because it depends on byte order, but we knew that already,
and we take care of it with #defines, and an optimizer should
not change its meaning.

At 03:05 PM 8/1/2002 -0700, David G Hough at validlab.com wrote:
>A couple of years ago Stephen Moshier wrote:
> 
> It is well known that fdlibm as originally posted was riddled with
> pointer aliasing bugs and other portability problems. 
...
>Is this still the current status?    
...
>The original libfdm problem with optimizers -
>finding an efficient way to access doubles as pairs of 32-bit ints -
>has been said to be insoluble since the C standard doesn't GUARANTEE any
>of the usual ways of doing so by pointers or unions.

David






More information about the Numeric-interest mailing list