https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55916
--- Comment #13 from Jouko Orava <jouko.orava at iki dot fi> --- (In reply to Joost VandeVondele from comment #12) > I'm wondering if you had a working patch at some point. Not a comprehensive one, no. I recall modifying libgfortran/runtime/memory.c was not sufficient. I ended up going pretty deep into how GCC generates the code in an effort to find out how to replace *all* calls to malloc(), free(), calloc(), and realloc() with fortran_malloc(), fortran_free(), fortran_calloc(), and fortran_realloc(), respectively, that GCC generates for Fortran code, with libgfortran initially providing wrappers around the respective C library calls. That way it would be possible to automagically choose whether the C library standard allocator was sufficient at the GCC compile time (based on maximum alignment versus largest non-vector type supported by the architecture), or if a higher-alignment allocator (memalign(), posix_memalign()) would be used instead. Or, better yet, even replace the C library allocator with a custom one, one that better caters to Fortran use cases. At some point I realized there was about zero percent chance such invasive changes would be accepted upstream, so I gave up. The workaround I showed in #11, https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55916#c11 suffices for me, after all; it basically does the replacement by interposing those functions on the C library side instead. It can be used either at compile time (by linking the C code into the final binary), or at run time for already-compiled binaries (by using LD_PRELOAD).