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 20:01:00 GMT 2018
On 10/09/2018 08:54 PM, Pedro Alves wrote:
> 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>.
Maybe we could make gdb::optional's ctor initialize the payload
only in devel mode, leave it uninitialized in release mode,
and add back -Werror for that warning. We'd see the warnings in
release mode, but releases don't use -Werror so it's less of
an issue.
Doesn't really fix the issue though, just papers over it.
Not sure that really helps.
Thanks,
Pedro Alves
More information about the Gdb
mailing list