https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93051
--- Comment #2 from Alexander Cherepanov <ch3root at openwall dot com> --- Example with a dead malloc (not in tree-opt): ---------------------------------------------------------------------- #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; } int main() { int *q = malloc(sizeof(int)); uintptr_t iq = (uintptr_t)(void *)q; free(q); int *p = malloc(sizeof(int)); uintptr_t ir = (uintptr_t)(void *)opaque(p); // hide provenance of p if (ir == iq) { *p = 1; *(int *)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) ----------------------------------------------------------------------