https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79768
Bug ID: 79768 Summary: `-Wmaybe-uninitialized' false positive with optimisation Product: gcc Version: 5.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: middle-end Assignee: unassigned at gcc dot gnu.org Reporter: caspervector at gmail dot com Target Milestone: --- The following source file (here called `gcc_bug.c') triggers `-Wmaybe-uninitialized' when compiled with `-Os', `-O1' or stronger optimisation, plus `-Wall': ------------------------------------------------------------------------ #include <stdio.h> #include <stdlib.h> static int mk (int **a, int **b, int **c) { if (!(*a = malloc (sizeof (int)))) goto a_err; if (!(*b = malloc (sizeof (int)))) goto b_err; if (!(*c = malloc (sizeof (int)))) goto c_err; return 1; c_err: free (*b); b_err: free (*a); a_err: return 0; } static void fin (int *a, int *b, int *c) { free (c); free (b); free (a); } int main (void) { int *a, *b, *c, x, flag = mk (&a, &b, &c); while ((x = getchar ()) != -1) { if (flag) switch (x) { case 0: break; default: goto retn; } else if (x) goto retn; } retn: if (flag) fin (a, b, c); return 0; } ------------------------------------------------------------------------