This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/69537] New: Incorrect -Wmaybe-uninitialized warning with enum variable
- From: "fw at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 28 Jan 2016 13:18:57 +0000
- Subject: [Bug middle-end/69537] New: Incorrect -Wmaybe-uninitialized warning with enum variable
- Auto-submitted: auto-generated
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;
}