Nvcc/cudafe 10.x with gcc on RHEL 7/CentOS7 introducing a syntax error when 0.0f is in program or header text

More details here

The follow program fails to compile on RedHat/CentOS linux 7 using cuda 10.x with gcc-4.8.5 or gcc7.
file “test_me.cu”:

    __host__ __device__
    float test_me(float v)
        if (v == 0.0f)    // note the 0.0f here and below.
            return v * 42;
        return v * v;

Compile command:
nvcc -c test_me.cu
Produces the error message:

    test_me.cu: In function float test_me(float):
    test_me.cu:6:14: error: expected ')' before numeric constant
     if (v == 0.0f)

If I examine the preprocessor output using by adding ‘–cuda’ to the nvcc command:
nvcc --cuda -c test_me.cu vi test_me.cu.cpp.ii

I see the following line:

    if (v == (nan.0F)) 

Where is that nan.0F coming from ??

nvcc --version 
$ nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2019 NVIDIA Corporation
Built on Sun_Jul_28_19:07:16_PDT_2019
Cuda compilation tools, release 10.1, V10.1.243

$ g++ -v 
Using built-in specs.
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-linker-hash-style=gnu --enable-languages=c,c++,objc,obj-c++,java,fortran,ada,go,lto --enable-plugin --enable-initfini-array --disable-libgcj --with-isl=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/isl-install --with-cloog=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/cloog-install --enable-gnu-indirect-function --with-tune=generic --with-arch_32=x86-64 --build=x86_64-redhat-linux
Thread model: posix
gcc version 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC)[nvidia-bug-report.log.gz|attachment](upload://gzxB1dc6TiogVwD5hhewpMTxJVS.gz) (905.9 KB)

I can now confirm that this is a bug in the -322 version of RedHat’s glibc packages.
I downgraded back to -317, and that fixed the problem.

$ yum downgrade glibc glibc-common glibc-devel glibc-headers to 0:2.17-317.el7

This problem may also manifest as a complaint “error: cannot convert ‘double (*)(const char*) throw ()’ to ‘long double’ in return”. In this case the line would be pointing to the header <limits> method denorm_min value LDBL_DENORM_MIN.

The yum downgrade command may also need “glibc-static” and “glibc-utils”.

I can also confirm that -323 fixes the issue, which is the route we took.