In SemaCUDA all implicit functions were considered host device, this led to errors such as the following code snippet failing to compile:
struct Copyable {
const Copyable& operator=(const Copyable& x) { return *this; }
};
struct Simple {
Copyable b;
};
void foo() {
Simple a, b;
a = b;
}Above the implicit copy assignment operator was inferred as host device but there was only a host assignment copy defined which is an error in device compilation mode.
This seems like another interesting test case:
struct Copyable { __device__ const Copyable& operator=(const Copyable& x) { return *this; } }; struct Simple { Copyable b; }; void foo(Simple &a, Simple &b) { a = b; }Simple's implicit copy ctor should be rejected when the host is the target because it calls a device-only method from the host, right?
I'm also curious what happens when someone uses FP math builtins like __builtin_cos that might have a reasonable lowering on a GPU.