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

Tom Tromey tom@tromey.com
Tue Oct 9 19:34:00 GMT 2018

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

>> 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.

Pedro> Really not sure whether that is possible.  I think there's hope
Pedro> that GCC value tracking becomes smart enough that these
Pedro> std::optional-related warnings end up disappearing (which usually
Pedro> means the code will optimize better too).  Fingers crossed, at least.

For gdb::optional, I think it would be good enough if we could simply
suppress the warning and make operator* assert that the object was
instantiated.  Perhaps std::optional could enforce this in debug mode as


More information about the Gdb mailing list