https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99509
--- Comment #1 from Tobias Burnus <burnus at gcc dot gnu.org> --- Variant which also is valid C: #pragma omp declare target int data[]={5}; #pragma omp end declare target inline int foo(int idx) { return data[idx]; } int main() { int i; #pragma omp target map(to:i) i = foo(0); return i; } Result as follows; enclosing the 'foo' in the declare-target block has no effect. With g++ this still fails with: bar2.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 But with cc it fails with: unresolved symbol foo mkoffload: fatal error: ...