https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88899
Tobias Burnus <burnus at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |burnus at gcc dot gnu.org, | |pault at gcc dot gnu.org Keywords| |wrong-code --- Comment #4 from Tobias Burnus <burnus at gcc dot gnu.org> --- The problem seems to be due to finalization. integer(kind=4) __final_mod_T (...) { static struct t * ptr2; ... } Calling this function concurrently fails as ptr2 is "static". The reason for 'static' is: #0 gfc_finish_var_decl (decl=0x7ffff71ac090, sym=0x2914580) at ../../repos/gcc/gcc/fortran/trans-decl.c:727 722 if (!sym->attr.use_assoc 723 && ((sym->ts.type == BT_DERIVED 724 && sym->ts.u.derived->attr.has_dtio_procs) 725 || (sym->ts.type == BT_CLASS 726 && CLASS_DATA (sym)->ts.u.derived->attr.has_dtio_procs))) 727 TREE_STATIC (decl) = 1; "ptr2" itself seems to come from class.c's finalizer_insert_packed_call. * * * That change was part of the huge commit https://gcc.gnu.org/g:e73d3ca6d1caf9c1187eeb1236dffd42f15ec043 for PR fortran/48298 (DTIO). The changelog states for this change: * trans-decl.c (gfc_finish_var_decl): If a derived-type/class object is associated with DTIO procedures, make it TREE_STATIC.