https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94660
--- Comment #2 from innspg at yahoo dot fr --- The bug was reproduced with the following version of gfortran: 6.3.0, 7.3.0, 7.5.0, 8.2.0, 8.4.0 and 9.2.0. gfortran 4.8.5 produces the expected result The expected output when the program is ran should be: Test: calling C%init B::init, calling setup C::setup B::init done ............... Test: calling C%finalize B::finalize, calling free_resources C::free_resources B::finalize, calling cleanup B::cleanup B::finalize done ................... Test:done....................... I am getting this instead: Test: calling C%init B::init, calling setup B::cleanup B::init done ............... Test: calling C%finalize B::finalize, calling free_resources C::setup B::finalize, calling cleanup B::cleanup B::finalize done ................... Test:done.......................