NVCC fails if C++11 activated and certain headers included

Hi,

I noticed that my code fails to build if I simultaneously activate C++11 (or C++14) and include certain system headers. A minimal example is attached below. Is this a way to work around this? (I’m working with a library based on C++ templates, so not including those headers or splitting CUDA code from host code into separate source files is not an option for me.)

#include <stdexcept>

int main(int argc, char **argv)
{
    return 0;
}

Compilation log:

gentryx@neuromancer ~ $ g++ --version
g++ (Gentoo 4.9.3 p1.0, pie-0.6.2) 4.9.3
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


09:51:04 - 0
gentryx@neuromancer ~ $ nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2015 NVIDIA Corporation
Built on Tue_Aug_11_14:27:32_CDT_2015
Cuda compilation tools, release 7.5, V7.5.17

09:51:09 - 0
gentryx@neuromancer ~ $ nvcc -v test.cu -Xcompiler "-std=c++11"
#$ _SPACE_= 
#$ _CUDART_=cudart
#$ _HERE_=/opt/cuda/bin
#$ _THERE_=/opt/cuda/bin
#$ _TARGET_SIZE_=
#$ _TARGET_DIR_=
#$ _TARGET_SIZE_=64
#$ TOP=/opt/cuda/bin/..
#$ NVVMIR_LIBRARY_DIR=/opt/cuda/bin/../nvvm/libdevice
#$ LD_LIBRARY_PATH=/opt/cuda/bin/../lib:
#$ PATH=/opt/cuda/bin/../open64/bin:/opt/cuda/bin/../nvvm/bin:/opt/cuda/bin:/usr/lib64/ccache/bin:/usr/lib/ccache/bin:/usr/local/bin:/usr/bin:/bin:/opt/bin:/usr/x86_64-pc-linux-gnu/gcc-bin/4.9.3:/opt/intel/composerxe-2015_update3.3.187/bin/intel64:/opt/intel/composerxe-2015_update3.3.187/mpirt/bin/intel64:/opt/intel/composerxe-2015_update3.3.187/bin/ia32:/opt/intel/composerxe-2015_update3.3.187/mpirt/bin/ia32:/opt/android-sdk-update-manager/tools:/opt/android-sdk-update-manager/platform-tools:/usr/games/bin:/opt/vmware/bin:/opt/cuda/bin:/opt/cuda/libnvvp:/opt/visit/bin
#$ INCLUDES="-I/opt/cuda/bin/..//include"  
#$ LIBRARIES=  "-L/opt/cuda/bin/..//lib64/stubs" "-L/opt/cuda/bin/..//lib64"
#$ CUDAFE_FLAGS=
#$ PTXAS_FLAGS=
#$ gcc -D__CUDA_ARCH__=200 -E -x c++        -DCUDA_DOUBLE_MATH_FUNCTIONS  -D__CUDACC__ -D__NVCC__  -std=c++11 "-I/opt/cuda/bin/..//include"   -D"__CUDACC_VER__=70517" -D"__CUDACC_VER_BUILD__=17" -D"__CUDACC_VER_MINOR__=5" -D"__CUDACC_VER_MAJOR__=7" -include "cuda_runtime.h" -m64 "test.cu" > "/tmp/tmpxft_0000460b_00000000-9_test.cpp1.ii" 
#$ cudafe --allow_managed --m64 --gnu_version=40903 -tused --no_remove_unneeded_entities  --gen_c_file_name "/tmp/tmpxft_0000460b_00000000-4_test.cudafe1.c" --stub_file_name "/tmp/tmpxft_0000460b_00000000-4_test.cudafe1.stub.c" --gen_device_file_name "/tmp/tmpxft_0000460b_00000000-4_test.cudafe1.gpu" --nv_arch "compute_20" --gen_module_id_file --module_id_file_name "/tmp/tmpxft_0000460b_00000000-3_test.module_id" --include_file_name "tmpxft_0000460b_00000000-2_test.fatbin.c" "/tmp/tmpxft_0000460b_00000000-9_test.cpp1.ii" 
/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/stddef.h(432): error: identifier "nullptr" is undefined

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/stddef.h(432): error: expected a ";"

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4/x86_64-pc-linux-gnu/bits/c++config.h(192): error: expected a ";"

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4/exception(63): error: expected a ";"

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4/exception(68): error: expected a ";"

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4/exception(76): error: expected a ";"

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4/exception(83): error: expected a ";"

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4/exception(93): error: expected a "{"

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4/bits/exception_ptr.h(64): error: function "std::current_exception" returns incomplete type "std::__exception_ptr::exception_ptr"

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4/bits/exception_ptr.h(64): error: expected a "{"

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4/bits/exception_ptr.h(79): error: expected a ";"

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4/bits/exception_ptr.h(81): error: expected a ";"

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4/bits/exception_ptr.h(82): error: expected a ";"

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4/bits/exception_ptr.h(84): error: expected a ";"

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4/bits/exception_ptr.h(86): error: declaration is incompatible with previous "std::current_exception"
(64): here

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4/bits/exception_ptr.h(86): error: use of a local type to declare a function

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4/bits/exception_ptr.h(86): error: expected a ";"

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4/bits/exception_ptr.h(87): error: use of a local type to declare a function

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4/bits/exception_ptr.h(90): error: expected a ";"

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4/bits/exception_ptr.h(92): error: expected a ";"

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4/bits/exception_ptr.h(95): error: incomplete type is not allowed

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4/bits/exception_ptr.h(95): error: expected a ";"

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4/bits/exception_ptr.h(116): error: expected a ";"

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4/bits/exception_ptr.h(126): error: expected a ";"

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4/bits/exception_ptr.h(143): error: use of a local type to declare a function

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4/bits/exception_ptr.h(144): error: expected a ";"

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4/bits/exception_ptr.h(147): error: expected a ";"

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4/bits/exception_ptr.h(152): error: use of a local type to declare a function

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4/bits/exception_ptr.h(153): error: expected a ";"

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4/bits/exception_ptr.h(156): error: use of a local type to declare a function

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4/bits/exception_ptr.h(157): error: expected a ";"

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4/bits/exception_ptr.h(160): error: use of a local type to declare a function

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4/bits/exception_ptr.h(161): error: expected a ";"

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4/bits/exception_ptr.h(169): error: expected a ";"

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4/bits/exception_ptr.h(193): error: expected a ";"

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4/bits/nested_exception.h(57): error: incomplete type is not allowed

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4/bits/nested_exception.h(60): error: expected a ";"

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4/bits/nested_exception.h(66): error: expected a ";"

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4/bits/nested_exception.h(70): error: identifier "rethrow_exception" is undefined

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4/bits/nested_exception.h(73): error: function "std::nested_exception::nested_ptr" returns incomplete type "std::__exception_ptr::exception_ptr"

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4/new(113): error: expected a "{"

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4/new(128): error: allocation operator may not be declared in a namespace

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4/new(130): error: allocation operator may not be declared in a namespace

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4/new(132): error: deallocation operator may not be declared in a namespace

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4/new(132): error: expected a "{"

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4/new(147): error: identifier "__p" is undefined

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4/new(148): error: allocation operator may not be declared in a namespace

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4/new(148): error: expected a "{"

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4/new(152): error: deallocation operator may not be declared in a namespace

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4/new(152): error: expected a "{"

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4/new(153): error: deallocation operator may not be declared in a namespace

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4/new(153): error: expected a "{"

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4/bits/cpp_type_traits.h(184): error: identifier "char16_t" is undefined

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4/bits/cpp_type_traits.h(191): error: identifier "char32_t" is undefined

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4/bits/cpp_type_traits.h(191): error: class "std::__is_integer<<error-type>>" has already been defined

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4/bits/cpp_type_traits.h(314): error: namespace "std::__gnu_cxx" has no member "__normal_iterator"

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4/bits/cpp_type_traits.h(314): error: expected a ">"

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4/ext/type_traits.h(159): error: inline specifier allowed on function declarations only

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4/ext/type_traits.h(160): error: declaration is incompatible with overloaded function "__gnu_cxx::__is_null_pointer"
(150): here

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4/ext/type_traits.h(160): error: namespace "std" has no member "nullptr_t"

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4/ext/type_traits.h(161): error: expected a ";"

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4/ext/type_traits.h(173): error: a template argument list is not allowed in a declaration of a primary template

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4/ext/type_traits.h(177): error: __promote is not a template

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4/ext/type_traits.h(181): error: __promote is not a template

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4/ext/type_traits.h(185): error: __promote is not a template

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4/ext/type_traits.h(189): error: __promote is not a template

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4/ext/type_traits.h(189): error: expected a ">"

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4/ext/type_traits.h(189): error: the global scope has no "__type"

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4/ext/type_traits.h(197): error: __promote is not a template

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4/ext/type_traits.h(197): error: expected a ">"

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4/ext/type_traits.h(197): error: the global scope has no "__type"

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4/ext/type_traits.h(206): error: __promote is not a template

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4/ext/type_traits.h(206): error: expected a ">"

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4/ext/type_traits.h(206): error: the global scope has no "__type"

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4/cmath(80): error: inline specifier allowed on function declarations only

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4/cmath(80): error: expected a ";"

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4/cmath(105): error: inline specifier allowed on function declarations only

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4/cmath(105): error: variable "std::constexpr" has already been defined

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4/cmath(105): error: expected a ";"

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4/cmath(124): error: inline specifier allowed on function declarations only

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4/cmath(124): error: variable "std::constexpr" has already been defined

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4/cmath(124): error: expected a ";"

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4/cmath(143): error: inline specifier allowed on function declarations only

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4/cmath(143): error: variable "std::constexpr" has already been defined

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4/cmath(143): error: expected a ";"

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4/cmath(162): error: inline specifier allowed on function declarations only

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4/cmath(162): error: variable "std::constexpr" has already been defined

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4/cmath(162): error: expected a ";"

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4/cmath(183): error: inline specifier allowed on function declarations only

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4/cmath(183): error: variable "std::constexpr" has already been defined

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4/cmath(183): error: expected a ";"

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4/cmath(202): error: inline specifier allowed on function declarations only

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4/cmath(202): error: variable "std::constexpr" has already been defined

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4/cmath(202): error: expected a ";"

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4/cmath(221): error: inline specifier allowed on function declarations only

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4/cmath(221): error: variable "std::constexpr" has already been defined

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4/cmath(221): error: expected a ";"

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4/cmath(240): error: inline specifier allowed on function declarations only

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4/cmath(240): error: variable "std::constexpr" has already been defined

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4/cmath(240): error: expected a ";"

Error limit reached.
100 errors detected in the compilation of "/tmp/tmpxft_0000460b_00000000-9_test.cpp1.ii".
Compilation terminated.
# --error 0x4 --

09:51:15 - 4
gentryx@neuromancer ~ $

According to the Linux Installation Guide for CUDA 7.5 [url]Installation Guide Linux :: CUDA Toolkit Documentation, gcc 4.9.3 is not supported on any of the supported Linux flavors. Seems you are in uncharted territory.

Thanks! I get the same error for GCC 4.9.2 though. :-/

gentryx@neuromancer ~ $ nvcc -v test.cu -Xcompiler "-std=c++11"
#$ _SPACE_= 
#$ _CUDART_=cudart
#$ _HERE_=/opt/cuda/bin
#$ _THERE_=/opt/cuda/bin
#$ _TARGET_SIZE_=
#$ _TARGET_DIR_=
#$ _TARGET_SIZE_=64
#$ TOP=/opt/cuda/bin/..
#$ NVVMIR_LIBRARY_DIR=/opt/cuda/bin/../nvvm/libdevice
#$ LD_LIBRARY_PATH=/opt/cuda/bin/../lib:
#$ PATH=/opt/cuda/bin/../open64/bin:/opt/cuda/bin/../nvvm/bin:/opt/cuda/bin:/usr/local/bin:/usr/bin:/bin:/opt/bin:/usr/x86_64-pc-linux-gnu/gcc-bin/4.9.2:/opt/intel/composerxe-2015_update3.3.187/bin/intel64:/opt/intel/composerxe-2015_update3.3.187/mpirt/bin/intel64:/opt/intel/composerxe-2015_update3.3.187/bin/ia32:/opt/intel/composerxe-2015_update3.3.187/mpirt/bin/ia32:/opt/android-sdk-update-manager/tools:/opt/android-sdk-update-manager/platform-tools:/usr/games/bin:/opt/vmware/bin:/opt/cuda/bin:/opt/cuda/libnvvp:/opt/visit/bin
#$ INCLUDES="-I/opt/cuda/bin/..//include"  
#$ LIBRARIES=  "-L/opt/cuda/bin/..//lib64/stubs" "-L/opt/cuda/bin/..//lib64"
#$ CUDAFE_FLAGS=
#$ PTXAS_FLAGS=
#$ gcc -D__CUDA_ARCH__=200 -E -x c++        -DCUDA_DOUBLE_MATH_FUNCTIONS  -D__CUDACC__ -D__NVCC__  -std=c++11 "-I/opt/cuda/bin/..//include"   -D"__CUDACC_VER__=70517" -D"__CUDACC_VER_BUILD__=17" -D"__CUDACC_VER_MINOR__=5" -D"__CUDACC_VER_MAJOR__=7" -include "cuda_runtime.h" -m64 "test.cu" > "/tmp/tmpxft_000022f4_00000000-9_test.cpp1.ii" 
#$ cudafe --allow_managed --m64 --gnu_version=40902 -tused --no_remove_unneeded_entities  --gen_c_file_name "/tmp/tmpxft_000022f4_00000000-4_test.cudafe1.c" --stub_file_name "/tmp/tmpxft_000022f4_00000000-4_test.cudafe1.stub.c" --gen_device_file_name "/tmp/tmpxft_000022f4_00000000-4_test.cudafe1.gpu" --nv_arch "compute_20" --gen_module_id_file --module_id_file_name "/tmp/tmpxft_000022f4_00000000-3_test.module_id" --include_file_name "tmpxft_000022f4_00000000-2_test.fatbin.c" "/tmp/tmpxft_000022f4_00000000-9_test.cpp1.ii" 
/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/stddef.h(432): error: identifier "nullptr" is undefined

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/stddef.h(432): error: expected a ";"

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/g++-v4/x86_64-pc-linux-gnu/bits/c++config.h(192): error: expected a ";"

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/g++-v4/exception(63): error: expected a ";"

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/g++-v4/exception(68): error: expected a ";"

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/g++-v4/exception(76): error: expected a ";"

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/g++-v4/exception(83): error: expected a ";"

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/g++-v4/exception(93): error: expected a "{"

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/g++-v4/bits/exception_ptr.h(64): error: function "std::current_exception" returns incomplete type "std::__exception_ptr::exception_ptr"

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/g++-v4/bits/exception_ptr.h(64): error: expected a "{"

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/g++-v4/bits/exception_ptr.h(79): error: expected a ";"

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/g++-v4/bits/exception_ptr.h(81): error: expected a ";"

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/g++-v4/bits/exception_ptr.h(82): error: expected a ";"

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/g++-v4/bits/exception_ptr.h(84): error: expected a ";"

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/g++-v4/bits/exception_ptr.h(86): error: declaration is incompatible with previous "std::current_exception"
(64): here

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/g++-v4/bits/exception_ptr.h(86): error: use of a local type to declare a function

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/g++-v4/bits/exception_ptr.h(86): error: expected a ";"

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/g++-v4/bits/exception_ptr.h(87): error: use of a local type to declare a function

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/g++-v4/bits/exception_ptr.h(90): error: expected a ";"

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/g++-v4/bits/exception_ptr.h(92): error: expected a ";"

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/g++-v4/bits/exception_ptr.h(95): error: incomplete type is not allowed

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/g++-v4/bits/exception_ptr.h(95): error: expected a ";"

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/g++-v4/bits/exception_ptr.h(116): error: expected a ";"

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/g++-v4/bits/exception_ptr.h(126): error: expected a ";"

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/g++-v4/bits/exception_ptr.h(143): error: use of a local type to declare a function

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/g++-v4/bits/exception_ptr.h(144): error: expected a ";"

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/g++-v4/bits/exception_ptr.h(147): error: expected a ";"

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/g++-v4/bits/exception_ptr.h(152): error: use of a local type to declare a function

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/g++-v4/bits/exception_ptr.h(153): error: expected a ";"

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/g++-v4/bits/exception_ptr.h(156): error: use of a local type to declare a function

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/g++-v4/bits/exception_ptr.h(157): error: expected a ";"

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/g++-v4/bits/exception_ptr.h(160): error: use of a local type to declare a function

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/g++-v4/bits/exception_ptr.h(161): error: expected a ";"

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/g++-v4/bits/exception_ptr.h(169): error: expected a ";"

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/g++-v4/bits/exception_ptr.h(193): error: expected a ";"

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/g++-v4/bits/nested_exception.h(57): error: incomplete type is not allowed

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/g++-v4/bits/nested_exception.h(60): error: expected a ";"

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/g++-v4/bits/nested_exception.h(66): error: expected a ";"

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/g++-v4/bits/nested_exception.h(70): error: identifier "rethrow_exception" is undefined

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/g++-v4/bits/nested_exception.h(73): error: function "std::nested_exception::nested_ptr" returns incomplete type "std::__exception_ptr::exception_ptr"

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/g++-v4/new(113): error: expected a "{"

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/g++-v4/new(128): error: allocation operator may not be declared in a namespace

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/g++-v4/new(130): error: allocation operator may not be declared in a namespace

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/g++-v4/new(132): error: deallocation operator may not be declared in a namespace

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/g++-v4/new(132): error: expected a "{"

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/g++-v4/new(147): error: identifier "__p" is undefined

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/g++-v4/new(148): error: allocation operator may not be declared in a namespace

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/g++-v4/new(148): error: expected a "{"

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/g++-v4/new(152): error: deallocation operator may not be declared in a namespace

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/g++-v4/new(152): error: expected a "{"

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/g++-v4/new(153): error: deallocation operator may not be declared in a namespace

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/g++-v4/new(153): error: expected a "{"

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/g++-v4/bits/cpp_type_traits.h(184): error: identifier "char16_t" is undefined

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/g++-v4/bits/cpp_type_traits.h(191): error: identifier "char32_t" is undefined

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/g++-v4/bits/cpp_type_traits.h(191): error: class "std::__is_integer<<error-type>>" has already been defined

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/g++-v4/bits/cpp_type_traits.h(314): error: namespace "std::__gnu_cxx" has no member "__normal_iterator"

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/g++-v4/bits/cpp_type_traits.h(314): error: expected a ">"

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/g++-v4/ext/type_traits.h(159): error: inline specifier allowed on function declarations only

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/g++-v4/ext/type_traits.h(160): error: declaration is incompatible with overloaded function "__gnu_cxx::__is_null_pointer"
(150): here

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/g++-v4/ext/type_traits.h(160): error: namespace "std" has no member "nullptr_t"

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/g++-v4/ext/type_traits.h(161): error: expected a ";"

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/g++-v4/ext/type_traits.h(173): error: a template argument list is not allowed in a declaration of a primary template

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/g++-v4/ext/type_traits.h(177): error: __promote is not a template

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/g++-v4/ext/type_traits.h(181): error: __promote is not a template

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/g++-v4/ext/type_traits.h(185): error: __promote is not a template

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/g++-v4/ext/type_traits.h(189): error: __promote is not a template

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/g++-v4/ext/type_traits.h(189): error: expected a ">"

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/g++-v4/ext/type_traits.h(189): error: the global scope has no "__type"

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/g++-v4/ext/type_traits.h(197): error: __promote is not a template

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/g++-v4/ext/type_traits.h(197): error: expected a ">"

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/g++-v4/ext/type_traits.h(197): error: the global scope has no "__type"

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/g++-v4/ext/type_traits.h(206): error: __promote is not a template

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/g++-v4/ext/type_traits.h(206): error: expected a ">"

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/g++-v4/ext/type_traits.h(206): error: the global scope has no "__type"

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/g++-v4/cmath(80): error: inline specifier allowed on function declarations only

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/g++-v4/cmath(80): error: expected a ";"

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/g++-v4/cmath(105): error: inline specifier allowed on function declarations only

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/g++-v4/cmath(105): error: variable "std::constexpr" has already been defined

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/g++-v4/cmath(105): error: expected a ";"

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/g++-v4/cmath(124): error: inline specifier allowed on function declarations only

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/g++-v4/cmath(124): error: variable "std::constexpr" has already been defined

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/g++-v4/cmath(124): error: expected a ";"

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/g++-v4/cmath(143): error: inline specifier allowed on function declarations only

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/g++-v4/cmath(143): error: variable "std::constexpr" has already been defined

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/g++-v4/cmath(143): error: expected a ";"

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/g++-v4/cmath(162): error: inline specifier allowed on function declarations only

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/g++-v4/cmath(162): error: variable "std::constexpr" has already been defined

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/g++-v4/cmath(162): error: expected a ";"

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/g++-v4/cmath(183): error: inline specifier allowed on function declarations only

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/g++-v4/cmath(183): error: variable "std::constexpr" has already been defined

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/g++-v4/cmath(183): error: expected a ";"

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/g++-v4/cmath(202): error: inline specifier allowed on function declarations only

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/g++-v4/cmath(202): error: variable "std::constexpr" has already been defined

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/g++-v4/cmath(202): error: expected a ";"

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/g++-v4/cmath(221): error: inline specifier allowed on function declarations only

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/g++-v4/cmath(221): error: variable "std::constexpr" has already been defined

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/g++-v4/cmath(221): error: expected a ";"

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/g++-v4/cmath(240): error: inline specifier allowed on function declarations only

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/g++-v4/cmath(240): error: variable "std::constexpr" has already been defined

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/g++-v4/cmath(240): error: expected a ";"

Error limit reached.
100 errors detected in the compilation of "/tmp/tmpxft_000022f4_00000000-9_test.cpp1.ii".
Compilation terminated.
# --error 0x4 --

If you are on a supported Linux platform and using the supported gcc version for that platform, you may want to file a bug report with NVIDIA. Note that according to the Installation Guide, gcc 4.9.2 is supported only on a few of the supported Linux versions; for most of the supported Linux versions only gcc versions prior to 4.9.2 are supported.

This is not the right way to tell nvcc to compile for c++11:

-Xcompiler “-std=c++11”

Just supply the -std=c++11 switch directly to nvcc:

nvcc -std=c++11 …

When I compile your code that way on gcc 4.8.2/Fedora 20 / CUDA 7.5, it compiles cleanly for me.

Sorry, I should have spotted the erroneous -Xcompiler switch but failed to do so. The reason that switch does not do the right thing is that the purpose of -Xcompiler is to pass command line arguments only to the host compiler. However C++11 support requires that it be turned on across all components of the tool chain.

Thanks guys, I can confirm this is working for me.