boost/function.hpp and CUDA <typeinfo> must be incl. before typeid?

I would like to use boost::function objects in host code contained in a CUDA file. However, when including <boost/function.hpp>, nvcc (CUDA 2.0 with VS2005 express) refuses to compile the code (which compiles in .cpp files with VS2005 express). The error message is:

function_base.hpp(507): error: must be included before typeid is used
function_base.hpp(507): error: no suitable user-defined conversion from “const type_info” to “const type_info” exists

The strange thing is that is included by function_base.hpp before typeid is used.

This annoys me also because it prohibits use of several other boost libraries since they include this file.

Did anyone else have this problem, or a solution?


it seems that I have the same problem.
Is there already a solution for this?


Compile the host code requiring boost as a c++ file directly with gcc (or MSVC if on windows).

I just came across a similar issue. Compiling a file that includes “boost/function.hpp” with nvcc causes this error (for me on Linux):


nvcc error : ‘cudafe++’ died due to signal 11 (Invalid memory reference)

Including the cuda runtime header and using gcc instead (or simply renaming the file works fine, but surely this is an bug in nvcc?

Same here, although I did get a more sensible error message

[codebox]/usr/include/boost/function/function_template.hpp(786): internal error: assertion failed: gen_initializer_constant: ran out of fields (/home/buildmeister/nightly/rel/gpgpu/toolkit/r2.1/compiler/edg/EDG_3.9/src/cp_gen_be.c, line 3295)

1 catastrophic error detected in the compilation of “CudaCollision.cpp1.ii”.

Compilation aborted.[/codebox]

I wonder if there’s a chance that a fix of this would make it into version 2.2?