Subject: [Boost-bugs] [Boost C++ Libraries] #11169: boost::optional triggers -Wmaybe-uninitialized errors in g++
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2015-04-06 16:24:34
#11169: boost::optional triggers -Wmaybe-uninitialized errors in g++
---------------------------------------------+-----------------------
Reporter: Mathias Stearn <redbeard0531@â¦> | Owner: fcacciola
Type: Bugs | Status: new
Milestone: To Be Determined | Component: optional
Version: Boost 1.57.0 | Severity: Problem
Keywords: |
---------------------------------------------+-----------------------
Example taken from StackOverflow question 21755206*
{{{
#include <boost/optional.hpp>
::boost::optional<int> getitem();
int go(int nr)
{
boost::optional<int> a = getitem();
boost::optional<int> b;
if (nr > 0)
b = nr;
if (a != b)
return 1;
return 0;
}
}}}
{{{
g++ -c -O2 -Wall /tmp/test.cpp
/tmp/test.cpp: In function âint go(int)â
/tmp/test.cpp:13:3: warning: â*((void*)& b +4)â may be used uninitialized
in this function [-Wmaybe-uninitialized]
if (a != b)
^
}}}
This has been reported as gcc bug 47679*.
Two workarounds that seem to work in my testing are value-initializing
dummy_ in the aligned_storage default constructor or adding an empty asm
statement that lists dummy_ as an output. Would it be possible to include
a fix in mainline boost?
* Sorry, but trac flags this as spam if I include direct links.
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/11169> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:18 UTC