https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119864
--- Comment #10 from Nathaniel Shead <nshead at gcc dot gnu.org> --- (In reply to Pilar Latiesa from comment #9) > (In reply to Nathaniel Shead from comment #4) > > > The assertion is thrown when streaming the generated function "omp declare > > reduction Op" because this is a DECL_LOCAL_DECL_P function but isn't on the > > BLOCK of sum, so we didn't stream it by value when we were supposed to. > > Is the BLOCK incorrectly set or does it lack a DECL_CONTEXT at all? > > Thanks I believe the BLOCK is incorrect. (gdb) p decl->decl_minimal.context $1 = <function_decl 0x7ffff75e5600 sum> It should have been streamed while streaming 'sum' in 'trees_out::core_vals': /* Miscellaneous common nodes. */ case BLOCK: if (state) { state->write_location (*this, t->block.locus); state->write_location (*this, t->block.end_locus); } /* DECL_LOCAL_DECL_P decls are first encountered here and streamed by value. */ for (tree decls = t->block.vars; decls; decls = DECL_CHAIN (decls)) { if (VAR_OR_FUNCTION_DECL_P (decls) && DECL_LOCAL_DECL_P (decls)) { /* Make sure this is the first encounter, and mark for walk-by-value. */ gcc_checking_assert (!TREE_VISITED (decls) && !DECL_TEMPLATE_INFO (decls)); mark_by_value (decls); } tree_node (decls); } tree_node (NULL_TREE); But (gdb) pt $1->decl_common.initial->block.vars <var_decl 0x7ffff75f51c8 Sum type <record_type 0x7ffff75e0bd0 T visited cxx-odr-p type_0 type_5 type_6 VOID align:8 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 0x7ffff75e0f18 context <translation_unit_decl 0x7ffff7426000 /home/wreien/m/f.cpp> template-info <template_info 0x7ffff75ddd48 template <template_decl 0x7ffff7410cc0 T> args <tree_vec 0x7ffff75f7340 length:1 elt:0 <template_parm_index 0x7ffff74308d0 type <integer_type 0x7ffff7428690 unsigned int> readonly constant visited decl <const_decl 0x7ffff740f8e8 d> index 0 level 1 orig_level 1>>> full-name "struct T<d>" no-binfo use_template=1 interface-unknown reference_to_this <reference_type 0x7ffff75fe1f8> chain <type_decl 0x7ffff75fc0a0 T>> used visited tree_2 tree_3 tree_6 read decl_5 VOID /home/wreien/m/f.cpp:16:6 align:8 warn_if_not_align:0 context <function_decl 0x7ffff75e5600 sum> initial <constructor 0x7ffff75f83a8> module 0:p1 purview attached exported> Unless there's some other part of the function that this omp reductions are attached to we should be streaming by value first.