I cannot declare a function #pragma omp declare target void foo( std::function<void()> x ) { ... even though x is, whenever I use it, declared as offloadable, too. The workaround is to make foo a template. It then works. Is this on purpose or a bug?
Please read https://gcc.gnu.org/bugs.html, partial snippets aren't really useful, we need self-contained (if possible minimal) testcases that we can compile. You also didn't say what the error was, so it is unclear if you got an error already from the host compilation, or only from the linking where it invokes the offloading compiler(s). Neither you've started which offloading you have configured.
Likely bug in calling code: declare required in declaration and around definition