https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94320
--- Comment #2 from Tobias Burnus <burnus at gcc dot gnu.org> --- (In reply to Jakub Jelinek from comment #1) > tried > + && !lto_stream_offload_p With that patch, I get 6 times "has been referenced in offloaded code but hasn't been marked to be included in the offloaded code". Thus, that's a useful patch for the code I looked at. All those those functions are template functions. (With -O0, the nvptx run-time compilers complains only about 3 of those functions.) > I'm afraid we need to actually implement properly the OpenMP 5.0 > automatic omp declare target discovery Yes, it looks like that. I think C++ code is mostly affected as one quickly ends up using 'operator[]' and similar functions, which are not always inlined. Additionally, template programming makes it harder for the user to mark those functions as 'declare target'.