Boost logo

Boost :

Subject: Re: [boost] [optional] Warnings about uninitialized values
From: Adam Romanek (romanek.adam_at_[hidden])
Date: 2014-06-23 02:32:59


On 22.06.2014 00:28, Andrey Semashev wrote:
> Hi,
>
> When I use boost::optional I often see gcc warnings about using possibly
> uninitialized values. I've seen such warnings in my projects outside Boost but
> now I encountered them in Boost.Log. Building the current develop with gcc 4.8
> I see this:
>
> (...)
>
> I suspect this may be a compiler bug. I tried to create a minimal example to
> reproduce it but the warning doesn't show in a simple context. However, I'd
> like it to be worked around somehow (unless it's an actual bug in
> boost::optional).
>
> Any suggestions? Am I missing a bug in my code?

Andrey,

I'm experiencing the same issue in my code where boost::optional is used
quite extensively.

Some time ago I found a bug report in GCC's Bugzilla [1] and a
StackOverflow thread [2] related to this issue. Additionally, clang
doesn't show any warnings in my code. Hence I assumed this is a bug in GCC.

It turns out that GCC provides a way to silence such warnings
selectively via a #pragma [3]. However, I'm not sure this is the right
way to go.

WBR,
Adam Romanek

[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47679
[2]
http://stackoverflow.com/questions/21755206/how-to-get-around-gcc-void-b-4-may-be-used-uninitialized-in-this-funct
[3] http://stackoverflow.com/a/5080980/1776942


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk