Subject: Re: [boost] [optional] Warnings about uninitialized values
From: Andrey Semashev (andrey.semashev_at_[hidden])
Date: 2014-06-23 04:16:17
On Monday 23 June 2014 08:32:59 Adam Romanek wrote:
> 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?
> 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  and a
> StackOverflow thread  related to this issue. Additionally, clang
> doesn't show any warnings in my code. Hence I assumed this is a bug in GCC.
Thank you for the links. It seems like this is the compiler bug, although I
don't compare optionals in my code. Some other code path must be triggering
> It turns out that GCC provides a way to silence such warnings
> selectively via a #pragma . However, I'm not sure this is the right
> way to go.
Yes, but I'm hesitant to silence the warning since it may reveal the actual
problems. I'll have to do that though if there's no other solution.
PS: I didn't notice there were two options for this, -Wmaybe-uninitialized and
-Wuninitialized. Perhaps disabling the former is not that much undesirable.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk