https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89723
Bug ID: 89723 Summary: Bogus maybe-uninitialized warning with -Og Product: gcc Version: 8.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: bunk at stusta dot de Target Milestone: --- gcc seems to disable this warning when building without optimization, but it is enabled with -Og: $ cat test.c typedef struct node234_Tag node234; struct node234_Tag { node234 *parent; node234 *kids[4]; int counts[4]; }; int add234_internal(node234 *r, void *e, int index) { node234 *n; int ki; if (r == 0) { return 0; } n = r; while (n) { if (index <= n->counts[0]) { ki = 0; } else if (index -= n->counts[0] + 1, index <= n->counts[1]) { ki = 1; } else return 0; if (!n->kids[ki]) break; n = n->kids[ki]; } return ki; } $ gcc -c -O0 -Wall -Werror test.c $ gcc -c -O1 -Wall -Werror test.c $ gcc -c -Og -Wall -Werror test.c test.c: In function ‘add234_internal’: test.c:11:9: error: ‘ki’ may be used uninitialized in this function [-Werror=maybe-uninitialized] int ki; ^~ cc1: all warnings being treated as errors $ Some upstream software builds with -Werror, which makes this a real problem when building a whole distribution like Yocto with -Og for debugging purposes. This can be reproduced on amd64 with all gcc versions supporting -Og from 4.8 to a recent gcc 9 snapshot.