https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109580
Bug ID: 109580
Summary: #pragma GCC diagnostic ignored "-Wanalyzer-fd-leak" is
ineffective
Product: gcc
Version: 13.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: analyzer
Assignee: dmalcolm at gcc dot gnu.org
Reporter: eggert at gnu dot org
Target Milestone: ---
Created attachment 54896
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54896&action=edit
compressed test program illustrating false positive
This is gcc (GCC) 13.0.1 20230401 (Red Hat 13.0.1-0), and I ran into this
problem when compiling Emacs. This is a regression compared to GCC 12.
Compile the attached compressed program with:
gzip -d emacs1.i.gz
gcc -fanalyzer -O2 -S emacs1.i
GCC will generate output starting with:
In function ‘Fdaemon_initialized’:
cc1: warning: leak of file descriptor ‘dup2(nfd, 0)’ [CWE-775]
[-Wanalyzer-fd-leak]
However, the first line of emacs1.i is:
#pragma GCC diagnostic ignored "-Wanalyzer-fd-leak"
so that diagnostic should not be emitted.