libstc++-v3 vs. c99 vendor headers

Robert Lipe
Wed Dec 6 19:31:00 GMT 2000

These two don't seem to play nicely together for me. ccos.c does this:

#include <math.h>
#include "mathconf.h"

   __complex__ double
ccos (__complex__ double x)
  __complex__ double res;

  if (!FINITE_P (__real__ x) || __imag__ x != __imag__ x)
      if (__real__ x == 0.0 || __imag__ x == 0.0)
          __real__ res = NAN;

When this is built with a vendor headers that knows about C99's nan,
the result isn't pretty.  I'm guessing that __real__ is actually a GCC
__real__ while NAN could be just any old NAN.  For my C99-aware headers,
this preprocesses down to:

      if (__real__ x == 0.0 || __imag__ x == 0.0)
          __real__ res = ((float) +(const union
                                    long double __x;
                                    unsigned char __c[sizeof (long double)];}
                          { .__c = { [8] = 0xff, 0xff} } .__x);
          __imag__ res = 0.0;

Which, of course, isn't legal becuase it mixes the vendor compiler's
concept of a NAN with the GCC desires for a NAN.  (How exactly this
works with our compiler is a mystery to me, but it does.  This is why
I'm not a compiler guy. :-)

Should that just be renamed to something outside of the C99 namespace?


More information about the Gcc-bugs mailing list