Nvc++: error: Undefined reference to memcmp after std::array::operator== on GPU


Compiling the code below using nvc++ -stdpar -std=c++17 with version 21.3 of the HPC SDK produces an nvlink error regarding an undefined reference to memcmp.

#include <array>
#include <algorithm>
#include <execution>

int main(int argc, char *argv[])
  using namespace std;
  const auto pol = execution::par_unseq;
  vector<array<size_t,1>> v(1024);

  for_each(pol, v.begin(), v.end(), [=](array<size_t,1> &a){ a == a; });

  return 0;

I am using Ubuntu 20.10. The link error is:

nvlink error   : Undefined reference to 'memcmp' in '/tmp/nvc++hH5fvhEttmGU.o'
pgacclnk: child process exit status 2: /opt/nvidia/hpc_sdk_multi/Linux_x86_64/21.3/compilers/bin/tools/nvdd


Thanks Paul.

It looks like the array’s operator== uses "lexicographical_compare” which has an inlined “memcmp” embedded in it.

I filed an issue report, TPR #29962, and we’ll have our team see what we can do to add support for this.


1 Like