https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93052
--- Comment #2 from Alexander Cherepanov <ch3root at openwall dot com> --- Example with a dead malloc (phiopt2): ---------------------------------------------------------------------- #include <stdint.h> #include <stdlib.h> #include <stdio.h> __attribute__((noipa,optnone)) // imagine it in a separate TU static void *opaque(void *p) { return p; } static int been_there = 0; static uintptr_t f(uintptr_t ip, uintptr_t iq) { if (ip == iq) { been_there = 1; return ip; } else { been_there = 0; return iq; } } int main() { int *q = malloc(sizeof(int)); opaque(q); uintptr_t iq = (uintptr_t)(void *)q; free(q); int *p = malloc(sizeof(int)); opaque(p); uintptr_t ip = (uintptr_t)(void *)p; uintptr_t ir = f(ip, iq); if (been_there) { *p = 1; *(int *)(void *)ir = 2; printf("result: %d\n", *p); } } ---------------------------------------------------------------------- $ gcc -std=c11 -pedantic -Wall -Wextra -Wno-attributes test.c && ./a.out result: 2 $ gcc -std=c11 -pedantic -Wall -Wextra -Wno-attributes -O3 test.c && ./a.out result: 1 ---------------------------------------------------------------------- gcc x86-64 version: gcc (GCC) 10.0.0 20191223 (experimental) ----------------------------------------------------------------------