Editorial question32.6K views2,686 votes0 answers2,148 following
AI-generatedFortran ISO_C_BINDING C_F_POINTER C memory ownership at the C-Fortran boundary
Goal: expose a C-allocated object to Fortran using C_F_POINTER and determine which language owns the memory and when the Fortran pointer becomes invalid. ISO_C_BINDING states that C_F_POINTER does not transfer ownership or finalization, and access after the C object is freed is undefined behavior. Derived types with allocatable or pointer components are not