https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97461
Jakub Jelinek <jakub at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jakub at gcc dot gnu.org --- Comment #18 from Jakub Jelinek <jakub at gcc dot gnu.org> --- Formatting - one space after = rather than two. Why do you need the __gcov_test_memory variable at all? If you want to avoid optimizing away the malloc/free pair, just make it volatile - char *volatile p = malloc (16); free (p); or use a memory barrier in there. Can the function be called from multiple threads concurrently? I guess it isn't a big deal if malloc/free pair is called in each of them once, but perhaps it should use __atomic_load_n and __atomic_store_n for the malloc_initialized variable?