On Thu, Dec 10, 2020 at 03:38:40PM +0100, Jakub Jelinek via Gcc-patches wrote: One further thing, the detach clause effectively writes to the var, so unless you mark the clause decl addressable as I've suggested, you should if (omp_shared_to_firstprivate_optimizable_decl_p (decl)) omp_mark_stores (gimplify_omp_ctxp->outer_context, decl); e.g. in gimplify_adjust_omp_clauses OMP_CLAUSE_DETACH: handling, to make sure that outer parallel/task etc. regions don't try to optimize the var from shared to firstprivate through OMP_CLAUSE_SHARED_READONLY flag on OMP_CLAUSE_SHARED.
Jakub