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?
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.
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 this problem.
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.
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.