https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106427
Simon Josefsson <simon at josefsson dot org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |simon at josefsson dot org --- Comment #1 from Simon Josefsson <simon at josefsson dot org> --- I ran into this problem too, here is a simple reproducer: $ gcc -Werror -Wuse-after-free=3 -g -O2 -o foo foo.c foo.c: In function 'main': foo.c:18:6: error: pointer may be used after 'free' [-Werror=use-after-free] 18 | if (strstr (in, "FOO")) | ^ foo.c:21:3: note: call to 'free' here 21 | free (in); | ^~~~~~~~~ cc1: all warnings being treated as errors #include <string.h> #include <stdlib.h> extern int readln (char **out); int main (void) { char *in = NULL; int i = 0; if (!readln (&in)) return 0; if (in == NULL) return 0; if (strstr (in, "FOO")) i = 1; free (in); in = NULL; if (!readln (&in)) return 0; if (in == NULL) return 0; free (in); return i; }