on-internet
← Community

How to get around GCC ‘*((void*)& b +4)’ may be used uninitialized in this function warning while using boost::optional

Stack Overflow ·

I have code similar to the following: #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; } When compiling with GCC 4.7.2 with Boost 1.53, using the following command: g++ -c -O2 -Wall -DNDEBUG The following warning is issued: 13:3: warning: ‘((void)& b +4)’ may be used uninitialized in this function [-Wmaybe-uninitialized] Apparently, the root problem lies with GCC. See GCC Bugzilla Does anyone know a workaround?

Comments

Sign in or sign up to comment and upvote.

No comments yet.