https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99509
Bug ID: 99509 Summary: [OpenMP] 'omp declare target' for global variable → "hasn't been marked to be included in the offloaded code" Product: gcc Version: 11.0 Status: UNCONFIRMED Keywords: openmp, rejects-valid Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: burnus at gcc dot gnu.org CC: cltang at gcc dot gnu.org, jakub at gcc dot gnu.org Target Milestone: --- The following code fails when compiled for offloading with: foo3.cc:2:7: error: variable 'data' has been referenced in offloaded code but hasn't been marked to be included in the offloaded code 2 | int data[]={5}; | ^ lto1: fatal error: errors during merging of translation units #pragma omp declare target int data[]={5}; #pragma omp end declare target struct my { inline const int& operator[](const int idx) const { return data[idx]; } }; int main() { int i; struct my cs; #pragma omp target map(to:i) i = cs[0]; return i; }