There are two levels of uninitialized analysis in gcc:
-Wuninitialized
: flags variables that are certainly used uninitialized-Wmaybe-uninitialized
: flags variables that are potentially used uninitialized
In gcc (*), -Wall
turns on both levels even though the latter has spurious warnings because the analysis is imperfect. Spurious warnings are a plague, so the simplest way to avoid them is to pass -Wno-maybe-uninitialized
(after -Wall
).
If you still want the warnings, but not have them cause build failure (through -Werror
) you can white list them using -Wno-error=maybe-uninitialized
.
(*) Clang does not activate -Wmaybe-uninitialized
by default precisely because it’s very imprecise and has a good number of false positives; I wish gcc followed this guideline too.