$ cat leak.c #include void test () { int fd = open("test", O_RDONLY); } void main(){} $ gcc-11.2.0 leak.c -fanalyzer leak.c: In function ‘test’: leak.c:6:1: warning: leak of FILE ‘fd’ [CWE-775] [-Wanalyzer-file-leak] 6 | } | ^ ‘test’: events 1-2 | | 5 | int fd = open("test", O_RDONLY); | | ^~~~~~~~~~~~~~~~~~~~~~ | | | | | (1) opened here | 6 | } | | ~ | | | | | (2) leaks here | $ cat leak-by-not-saving.c #include void test () { open("test", O_RDONLY); } void main(){} $ gcc leak-by-not-saving.c -fanalyzer leak.c: In function ‘test’: leak.c:5:4: warning: leak by not saving fd [CWE-775] [-Wanalyzer-file-leak] 5 | open("test", O_RDONLY); | ^~~~~~~~~~~~~~~~~~~~~~ ‘test’: event 1 | | 5 | open("test", O_RDONLY); | | ^~~~~~~~~~~~~~~~~~~~~~ | | | | | (1) leak by not saving fd |