The documentation for the -Wmaybe-uninitialized option includes an example similar to the one below to demonstrate the conditions under which GCC is expected to issue a diagnostic. However, GCC fails to issue the expected diagnostic when the option is used (it does issue it with -Wall, -Wextra, and, contrary to expectations, with -Wuninitialized). $ (set -x && cat t.c && for w in all extra uninitialized maybe-uninitialized; do gcc -O2 -Werror -W$w -c -o/dev/null t.c && echo success; done) + cat t.c void foo (int); void bar (int y) { int x; switch (y) { case 1: x = 1; break; case 2: x = 4; break; case 3: x = 5; } foo (x); } + for w in all extra uninitialized maybe-uninitialized + gcc -O2 -Werror -Wall -c -o/dev/null t.c t.c: In function ‘bar’: t.c:12:9: error: ‘x’ may be used uninitialized in this function [-Werror=maybe-uninitialized] foo (x); ^ cc1: all warnings being treated as errors + for w in all extra uninitialized maybe-uninitialized + gcc -O2 -Werror -Wextra -c -o/dev/null t.c t.c: In function ‘bar’: t.c:12:9: error: ‘x’ may be used uninitialized in this function [-Werror=maybe-uninitialized] foo (x); ^ cc1: all warnings being treated as errors + for w in all extra uninitialized maybe-uninitialized + gcc -O2 -Werror -Wuninitialized -c -o/dev/null t.c t.c: In function ‘bar’: t.c:12:9: error: ‘x’ may be used uninitialized in this function [-Werror=maybe-uninitialized] foo (x); ^ cc1: all warnings being treated as errors + for w in all extra uninitialized maybe-uninitialized + gcc -O2 -Werror -Wmaybe-uninitialized -c -o/dev/null t.c + echo success success
Seems like a dup. *** This bug has been marked as a duplicate of bug 59223 ***