This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug middle-end/69537] New: Incorrect -Wmaybe-uninitialized warning with enum variable


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

            Bug ID: 69537
           Summary: Incorrect -Wmaybe-uninitialized warning with enum
                    variable
           Product: gcc
           Version: 6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: fw at gcc dot gnu.org
  Target Milestone: ---

gcc -O2 -Wall yields:

t.c: In function âyp_updateâ:
t.c:27:3: warning: âmasterâ may be used uninitialized in this function
[-Wmaybe-uninitialized]
   __builtin_free (master); // -Wmaybe-uninitialized warning here
   ^~~~~~~~~~~~~~~~~~~~~~~

According to Jakub Jelinek, this started with r225861.


enum clnt_stat {
 RPC_SUCCESS=0,
 RPC_CANTENCODEARGS=1,
};

int do_ypcall_tr ();

static int
yp_master (char **outname)
{
  // Replacing enum clnt_stat with int avoids the warning.
  enum clnt_stat result;
  result = do_ypcall_tr ();
  if (result != 0)
    return result;
  *outname = __builtin_strdup ("foo");
  return 0;
}

int
yp_update (void)
{
  char *master;
  int r;
  if ((r = yp_master (&master)) != 0)
    return r;
  __builtin_free (master); // -Wmaybe-uninitialized warning here
  return 0;
}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]