Error when compiling a CUDA program: invalid type argument of unary ‘*’ (have ‘int’)

479 views Asked by At

I (or somebody else) is compiling a CUDA program (e.g. vectorAdd from the cuda-api-wrappers library) using CUDA 11.6 and GCC 12.1, with C++17 set as the language standard. I get the following error:

/usr/include/c++/12.1.0/bits/locale_facets_nonio.tcc: In member function ‘_InIter std::__cxx11::time_get<_CharT, _InIter>::get(iter_type, iter_type, std::ios_base&, std::ios_base::iostate&, tm*, const char_type*, const char_type*) const’:
/usr/include/c++/12.1.0/bits/locale_facets_nonio.tcc:1477:77: error: invalid type argument of unary ‘*’ (have ‘int’)
 1477 |       if ((void*)(this->*(&time_get::do_get)) == (void*)(&time_get::do_get))
      |                                                                             ^   

This is weird, since I can't seem to relate it to anything in the program or the header-only library. Also, the error goes away if we compile using the C++14 language standard.

What exactly is the problem here, and how can I work around it / fix it?

1

There are 1 answers

0
einpoklum On

CUDA 11.6 is known to be incompatible with GCC 12.x; see:

CUDA incompatible with my gcc version

The error you see is probably due to this incompatibility, and will go away if you use GCC 11.x.