[Bug c++/43915] Compiler flags error: error: invalid initialization of reference of type 'boost::thread&&' from expression of type 'boost::thread'

redi at gcc dot gnu dot org gcc-bugzilla@gcc.gnu.org
Wed Apr 28 11:15:00 GMT 2010



------- Comment #5 from redi at gcc dot gnu dot org  2010-04-28 11:15 -------
I think this error is correct:

./boost/thread/pthread/thread_heap_alloc.hpp: In function 'T*
boost::detail::heap_new(A1&&) [with T = boost::detail::thread_data<void (*)()>,
A1 = void (*&)()]':
./boost/thread/detail/thread.hpp:130:95:   instantiated from here
./boost/thread/pthread/thread_heap_alloc.hpp:24:47: error: cannot bind 'void
(*)()' lvalue to 'void (*&&)()'
./boost/thread/detail/thread.hpp:43:13: error:   initializing argument 1 of
'boost::detail::thread_data<F>::thread_data(F&&) [with F = void (*)()]'

A1 is deduced as an lvalue-reference, so reference-collapsing means that
static_cast<A1&&> is a cast to an lvalue-reference, which won't bind to the
rvalue-reference parameter.

And I also think this error is correct:

./boost/thread/detail/thread.hpp: In function 'boost::thread&&
boost::move(boost::thread&&)':
./boost/thread/detail/thread.hpp:349:16: error: invalid initialization of
reference of type 'boost::thread&&' from expression of type 'boost::thread'

Although the diagnostic is misleading. The code is:

    inline thread&& move(thread&& t)
    {
        return t;
    }

At the point of return 't' is an lvalue so to return it as an rvalue it needs
to be static_cast<thread&&>(t)

I think this is INVALID


-- 

redi at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |redi at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43915



More information about the Gcc-bugs mailing list