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.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.8.5/lto-wrapper
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)