我有类似于以下的代码:
#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;
}
使用 Boost 1.53 编译 GCC 4.7.2 时,使用以下命令:
g++ -c -O2 -Wall -DNDEBUG
发出以下警告:
13:3:警告:'<em>((void)& b +4)' 可能在此函数中未初始化 [-Wmaybe-uninitialized]
显然,根本问题在于 GCC。请参阅GCC Bugzilla 有人知道解决方法吗?