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; }