NVCC attempting to compile __device__ version of class method unexpectedly

I’m working on porting an app to GPU, which has consisted of simply prepending __host__ __device__ for many functions which are not performance-critical. I have been lately stuck by what is either blindness on my behalf or a compiler bug.

To be brief, if I have a constructor for a class called “Cell” defined as follows:

class Cell {
  explicit Cell(pugi::xml_node cell_node);
  __host__ Cell() {}
  __host__ virtual ~Cell() {}
  __host__ __device__ temperature(unsigned indx);
  double temperature_;
  string name_;

Where string is a class that can only be constructed on the host, but I copy to device after construction.

Amazingly, when I try to compile this part of my code, I see the following error:

error: calling a __host__ function("string::string") from a __device__ function("Cell::Cell") is not allowed

But I don’t want NVCC to compile __device__ code for the Cell constructor! Why is this happening? I have clearly marked my default constructor as host only. I am unable to produce this in a complete MWE at the moment.

It seems the error goes away if I remove the virtual destructor. Why is that the case?

Followup: This seems to be happening because I had another piece of code calling an rvalue constructor of the class Cell later on in the code on the device. The error was reporting a seemingly unrelated line number though, which misled me. Adding a defaulted rvalue constructor fixed things for me. Not sure why this helped though.