https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97108

            Bug ID: 97108
           Summary: Wmaybe-uninitialized false positive
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: clyon at gcc dot gnu.org
  Target Milestone: ---

This testcase causes a false positive 'may be used uninitialized' warning when
compiled with -O2 -Wall. It is derived from libiberty/pex-win32.c
=================================================
#define STDIN_FILENO 0
#define STDOUT_FILENO 1
#define STDERR_FILENO 2

int _close(int);

int
pex_win32_exec_child (int flags,
                      int in, int out, int errdes)
{
  int pid = flags;
  int orig_err;
  int separate_stderr = !(flags);

  if (separate_stderr)
    {
      orig_err = errdes;
    }

  if (pid != (int) -1)
    {
      if (in != STDIN_FILENO)
        _close (in);
      if (out != STDOUT_FILENO)
        _close (out);
      if (separate_stderr
          && orig_err != STDERR_FILENO)
        _close (orig_err);
    }

  return pid;
}
=================================================

../pex-win32.c: In function ‘pex_win32_exec_child’:
../pex-win32.c:27:23: warning: ‘orig_err’ may be used uninitialized in this
function [-Wmaybe-uninitialized]
   27 |           && orig_err != STDERR_FILENO)
      |                       ^

Reply via email to