https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127174
--- Comment #1 from Tobias Burnus <burnus at gcc dot gnu.org> ---
The following works - the question is only whether that's the proper fix.
TODO: Besides fixing the issue (or checking whether this is the proper fix),
add more tests, including nested 'target' (reverse offload).
--- a/gcc/cp/semantics.cc
+++ b/gcc/cp/semantics.cc
@@ -11577,6 +11577,8 @@ finish_omp_target_clauses (location_t loc, tree body,
tree *clauses_ptr)
i != data.lambda_objects_accessed.end (); ++i)
{
tree lobj = *i;
+ if (LAMBDA_TYPE_P (TREE_TYPE (lobj)) && TREE_CODE (lobj) == INIT_EXPR)
+ continue;
if (TREE_CODE (lobj) == TARGET_EXPR)
lobj = TARGET_EXPR_SLOT (lobj);