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

Tom Tromey <[email protected]>
Newsgroups gmane.comp.gdb.devel
Message-ID <[email protected]>
>>>>> "Pedro" == Pedro Alves <[email protected]> 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.

Tom
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.