https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109839
Donald Buczek <buczek at molgen dot mpg.de> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |buczek at molgen dot mpg.de --- Comment #1 from Donald Buczek <buczek at molgen dot mpg.de> --- Correct, dup2() does not allocate a new file descriptor, so the returned file descriptor can't be leaked. Reduced test case: #include <unistd.h> void f(int old, int new) { int r = dup2(old, new); } https://gcc.godbolt.org/z/6sP9v1r5a