[Bug c++/94008] "use of deleted function" error when using "std::unique_ptr", std::move() and lambda
xerofoify at gmail dot com
gcc-bugzilla@gcc.gnu.org
Tue Mar 3 05:12:00 GMT 2020
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94008
Nicholas Krause <xerofoify at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |xerofoify at gmail dot com
--- Comment #1 from Nicholas Krause <xerofoify at gmail dot com> ---
I tried compiling this on both clang trunk and gcc trunk on godbolt. Your
problem seems to be this:
test_lambda([test_uniq = std::move(test_uniq)] {
test_lambda([test_uniq = std::move(test_uniq)] {});
})
Your passing into std::move and then again. That's incorrect as your moving and
moving again into the test_lamba. I tried with:
test_lambda([test_uniq = test_uniq.get()]() mutable {
test_lambda([test_uniq = std::move(test_uniq)] {});
});
And this does not miscompile due to test uniq getting the actual reference
rather than the r value and going back into another r value reference. This
therefore is not a bug.
More information about the Gcc-bugs
mailing list