https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113329
--- Comment #2 from Alan Coopersmith <alan.coopersmith at oracle dot com> --- I've hit this as well with gcc 13.2 when building xfs with -fanalyzer. I extracted this test case from https://gitlab.freedesktop.org/xorg/app/xfs/-/blob/master/os/daemon.c and when built with "gcc -fanalyzer -c dup2.c" it reports: dup2.c: In function ‘DetachStdio’: dup2.c:23:13: warning: ‘dup2’ on possibly invalid file descriptor ‘0’ [-Wanalyzer-fd-use-without-check] 23 | if (dup2(nullfd, 0) == -1) { | ^~~~~~~~~~~~~~~ ‘DetachStdio’: events 1-6 | | 10 | close (0); | | ^~~~~~~~~ | | | | | (1) closed here |...... | 18 | if (nullfd == -1) { | | ~ | | | | | (2) following ‘false’ branch (when ‘nullfd != -1’)... |...... | 22 | if (nullfd != 0) { | | ~ | | | | | (3) ...to here | | (4) following ‘true’ branch (when ‘nullfd != 0’)... | 23 | if (dup2(nullfd, 0) == -1) { | | ~~~~~~~~~~~~~~~ | | | | | (5) ...to here | | (6) ‘0’ could be invalid |