https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127559
--- Comment #3 from Tobias Burnus <burnus at gcc dot gnu.org> ---
The following fixes this issue and the testsuite,
but I am not sure it is correct nor whether it is complete.
When fixing: Also test reverse offload (i.e. nested 'omp target').
--- a/gcc/cp/semantics.cc
+++ b/gcc/cp/semantics.cc
@@ -11583,6 +11583,9 @@ finish_omp_target_clauses (location_t loc, tree body,
tree *clauses_ptr)
tree lt = TREE_TYPE (lobj);
gcc_assert (LAMBDA_TYPE_P (lt) && CLASS_TYPE_P (lt));
+ if (TREE_CODE (lobj) == INIT_EXPR)
+ continue;
+
tree lc = build_omp_clause (loc, OMP_CLAUSE_MAP);
OMP_CLAUSE_SET_MAP_KIND (lc, GOMP_MAP_TO);
OMP_CLAUSE_DECL (lc) = lobj;