https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102579
Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |alias --- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> --- But interesting GCC can remove malloc/free if the volatile was a non-local: extern"C" void *malloc(decltype(sizeof(0))); extern "C" void free(void*); void test_unused(volatile int *a) { volatile int d; int *p; p = (int*)malloc(sizeof(int)); d; free(p); } volatile int t; void test_unused1(void) { int *p; p = (int*)malloc(sizeof(int)); t; free(p); }