Re: gcc warning with "some variable may be used uninitialized in this function [-Wmaybe-uninitialized]" when building under msys

Tom Tromey
2018-10-05T05:08:14Z

>>>>> "Pedro" == Pedro Alves <palves@redhat.com> writes:

Pedro> If the warnings confuse people too much, I'd be OK with
Pedro> disabling -Wmaybe-uninitlized completely. I left it as a
Pedro> -Wno-error warning because even though it produces false positives,
Pedro> it also helps catch bugs earlier in the compile-edit cycle,
Pedro> when you're hacking some code, when you're introducing
Pedro> uninitialized uses, and "make" ends up compiling just a few
Pedro> files.

It caught a bug in the -Wshadow=local series; and I think in most cases
the false reports are easily handled with an initialization. I suppose
in theory these initializations could themselves mask bugs, but I don't
recall that ever actually happening (or at least being noticed).

It would be good if gcc could recognize std::optional and not issue the
warning when it is used. Perhaps gdb could then just always use
optional for the maybe-not-initialized cases.

Tom