pointer casting with C backend?

I have used the --host-compilation=C argument which according to the documentation uses the C language instead of C++ for compiling the host code (i prefer C to C++). However the following:

float* a;

hst_a = malloc(sizeof(float)*n);

while valid C code, produces an error:

test1.cu(28): error: a value of type "void *" cannot be assigned to an entity of type "float *"

if i add a typecast

hst_a = (char*)malloc(sizeof(float)*n);

then it works, but this is required only in C++, not C.

Isn’t this a bug in nvcc? Am i missing something? This isn’t a serious issue, but i would like to avoid all the unneeded typecasts.

What happens why you try to use a C++ construct like a template?

Templates work regardless of --host-compilation=C, --host-compilation=C++, --host-compilation C or --host-compilation C++ (i saw both uses). I tried with classes too and they work in “–host-compilation=C” mode.

So i assume this is a bug right? The compiler uses the C++ backend no matter what i specify.

EDIT: i made this blog post about my experience with CUDA so far :-)