https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82707
--- Comment #6 from Tom de Vries <vries at gcc dot gnu.org> --- (In reply to Jakub Jelinek from comment #5) > If the problem is missing unsharing, Minimal example (with c compiler and -fexceptions): ... extern void bar (void); void foo (void) { int e[8]; #pragma acc declare create (e) bar (); } ... At eh_opt, we have the map-delete clause in a finally: ... try { .omp_data_arr.2.e = &e; #pragma omp target oacc_declare map(force_alloc:e [len: 32]) .omp_data_arr.2 = {CLOBBER}; bar (); goto <D.1959>; } finally { .omp_data_arr.5.e = &e; #pragma omp target oacc_declare map(delete:e) .omp_data_arr.5 = {CLOBBER}; e = {CLOBBER}; } ... Then at eh, we see that it has been copied: ... .omp_data_arr.2.e = &e; #pragma omp target oacc_declare map(force_alloc:e [len: 32]) .omp_data_arr.2 = {CLOBBER}; bar (); goto <D.1961>; <D.1961>: .omp_data_arr.5.e = &e; #pragma omp target oacc_declare map(delete:e) .omp_data_arr.5 = {CLOBBER}; e = {CLOBBER}; goto <D.1959>; <D.1959>: return; <D.1960>: .omp_data_arr.5.e = &e; #pragma omp target oacc_declare map(delete:e) .omp_data_arr.5 = {CLOBBER}; e = {CLOBBER}; resx 1 ... The copy is done using gimple_copy. The patch to gimple_copy fixes the ICE by unsharing the tree parts of GIMPLE_OMP_TARGET (apart from gimple_omp_target_child_fn, which is a FUNCTION_DECL, which AFAIU can be shared).