Community Edition user here. Not sure where to report this…
I’m writing a script to detect the bit representation of floating point numbers for different compilers, operating systems, and CPU architectures, and am trying to use it with the PGI compiler. One of the things my script does is compile a NAN float as a const expression. Unfortunately, the PGI compiler doesn’t support this. When I try to compile the following:
#include <math.h>
static const float my_nan = NAN;
int main(void)
{
return 0;
}
I get the following error:
PGC-S-0074-Non-constant expression in initializer (main.c: 3)
PGC/power Linux 19.10-0: compilation completed with severe errors
This is due to how NAN is defined in math.h:
/* On GCC 8, the definition of NAN is something that pgcc doesn't handle very
* well. Change the definition to something else. */
#undef NAN
static union { unsigned char __c[4]; float __d; } __pgi_nan_union
__attribute_used__ = { { 0, 0, 0xc0, 0x7f } };
#define NAN (__pgi_nan_union.__d)
#endif