https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96835

--- Comment #7 from Tobias Weinzierl <tobias.weinzierl at durham dot ac.uk> ---
Adding a default constructor to the vector class still does not allow us to
create the object on the target:

#include <iostream>

#define mydt double

#pragma omp declare target
struct vector {  
  vector() {};
  vector(mydt x, mydt y);
  mydt dot(vector o);
  mydt v[2];
}; 

vector::vector(mydt x, mydt y) {
  v[0]=x;
  v[1]=y;
}

mydt vector::dot(vector o) { return v[0] * o.v[0] + v[1]*o.v[1]; }  
#pragma omp end declare target

int main() {
  mydt res;
  vector v1(1,1);
  vector v2(1,3);
  #pragma omp target map(from:res)
  {
    vector v3;
    res = v1.dot(v2); 
  }
  std::cout << res << "\n";
}


However, if we replace the default constructor with a default clause, then we
ca finally create a vector on the GPU, too:

#pragma omp declare target
struct vector {  
  vector() = default;
  [...]

Reply via email to