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

Pedro Alves palves@redhat.com
Tue Oct 9 19:54:00 GMT 2018


On 10/09/2018 08:33 PM, Tom Tromey wrote:
>>>>>> "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
> well.

Last I tried, I couldn't find a way to suppress the warning from
gdb::optional.  The warning triggers in code that belongs to
T in gdb::optional<T>.

Thanks,
Pedro Alves



More information about the Gdb mailing list