https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86465
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2019-06-12
See Also| |https://gcc.gnu.org/bugzill
| |a/show_bug.cgi?id=84299
Ever confirmed|0 |1
--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> ---
This is taken from the libstdc++ testsuite:
#include <functional>
#include <assert.h>
int f1() { return 1; }
struct { int operator()() { return 2; } } f2;
void test01()
{
typedef std::function<int()> function;
function fo(f1);
function fo1;
fo1 = (std::move(fo));
assert( static_cast<bool>(fo1) );
assert( fo1() == 1 );
fo = function(f2);
function fo2;
fo2 = (std::move(fo));
assert( static_cast<bool>(fo2) );
assert( fo2() == 2 );
}
int main()
{
test01();
}
Since GCC 7 this gives warnings when -Wsystem-headers -Wuninitialized -O1 is
used:
In file included from
/xhome/jwakely/gcc/10/include/c++/10.0.0/bits/stl_function.h:60,
from /xhome/jwakely/gcc/10/include/c++/10.0.0/functional:49,
from uninit.cc:1:
/xhome/jwakely/gcc/10/include/c++/10.0.0/bits/move.h: In function 'void
test01()':
/xhome/jwakely/gcc/10/include/c++/10.0.0/bits/move.h:193:7: warning:
'<anonymous>' is used uninitialized in this function [-Wuninitialized]
193 | __a = _GLIBCXX_MOVE(__b);
| ^~~
/xhome/jwakely/gcc/10/include/c++/10.0.0/bits/move.h:192:11: warning:
'<anonymous>' may be used uninitialized in this function
[-Wmaybe-uninitialized]
192 | _Tp __tmp = _GLIBCXX_MOVE(__a);
| ^~~~~
/xhome/jwakely/gcc/10/include/c++/10.0.0/bits/move.h:193:7: warning:
'<anonymous>' may be used uninitialized in this function
[-Wmaybe-uninitialized]
193 | __a = _GLIBCXX_MOVE(__b);
| ^~~
/xhome/jwakely/gcc/10/include/c++/10.0.0/bits/move.h:193:7: warning:
'*((void*)&<anonymous> +24)' may be used uninitialized in this function
[-Wmaybe-uninitialized]
193 | __a = _GLIBCXX_MOVE(__b);
| ^~~
/xhome/jwakely/gcc/10/include/c++/10.0.0/bits/move.h:193:7: warning:
'<anonymous>' may be used uninitialized in this function
[-Wmaybe-uninitialized]
193 | __a = _GLIBCXX_MOVE(__b);
| ^~~
valgrind and UBsan don't report any problems though.