Opened 13 years ago

Closed 12 years ago

#3844 closed Patches (fixed)

boost.thread doesn't work with gcc-4.5 in c++0x mode

Reported by: Sebastian Mingramm <s.mingramm@…> Owned by: Anthony Williams
Milestone: Boost 1.42.0 Component: thread
Version: Boost 1.41.0 Severity: Problem
Keywords: Cc:

Description

$ cat test.cpp 
#include <boost/thread.hpp>
int main() {}

$ g++ -v

Using built-in specs. COLLECT_GCC=g++ COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-pc-linux-gnu/4.5.0/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: ./configure --host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --disable-altivec --disable-fixed-point --with-ppl --with-cloog --disable-nls --with-system-zlib --disable-checking --disable-werror --enable-secureplt --enable-multilib --enable-libmudflap --disable-libssp --enable-libgomp --enable-cld --enable-languages=c,c++ --enable-shared --enable-threads=posix --enable-cxa_atexit --enable-clocale=gnu --enable-lto Thread model: posix gcc version 4.5.0 20100115 (experimental) (GCC)

$ g++ test.cpp -std=c++0x

In file included from /usr/include/boost/thread/thread.hpp:22:0,

from /usr/include/boost/thread.hpp:13, from test.cpp:1:

/usr/include/boost/thread/detail/thread.hpp: In function 'boost::thread&& boost::move(boost::thread&&)': /usr/include/boost/thread/detail/thread.hpp:349:16: error: invalid initialization of reference of type 'boost::thread&&' from expression of type 'boost::thread' In file included from /usr/include/boost/thread/detail/thread_heap_alloc.hpp:17:0,

from /usr/include/boost/thread/detail/thread.hpp:13, from /usr/include/boost/thread/thread.hpp:22, from /usr/include/boost/thread.hpp:13, from test.cpp:1:

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

from /usr/include/boost/thread/mutex.hpp:16, from /usr/include/boost/thread/pthread/thread_data.hpp:12, from /usr/include/boost/thread/thread.hpp:17, from /usr/include/boost/thread.hpp:13, from test.cpp:1:

/usr/include/boost/thread/locks.hpp: In member function 'boost::unique_lock<Mutex>& boost::unique_lock<Mutex>::operator=(boost::unique_lock<Mutex>&&) [with Mutex = boost::mutex, boost::unique_lock<Mutex> = boost::unique_lock<boost::mutex>]': /usr/include/boost/thread/future.hpp:414:91: instantiated from here /usr/include/boost/thread/locks.hpp:269:13: error: cannot bind 'boost::unique_lock<boost::mutex>' lvalue to 'boost::unique_lock<boost::mutex>&&' /usr/include/boost/thread/locks.hpp:279:14: error: initializing argument 1 of 'void boost::unique_lock<Mutex>::swap(boost::unique_lock<Mutex>&&) [with Mutex = boost::mutex, boost::unique_lock<Mutex> = boost::unique_lock<boost::mutex>]'

Attachments (3)

thread.diff (446 bytes ) - added by anonymous 13 years ago.
locks.diff (410 bytes ) - added by trueorca@… 13 years ago.
Egor Dmitrenkov
thread_heap_alloc.diff (530 bytes ) - added by trueorca@… 13 years ago.

Download all attachments as: .zip

Change History (8)

by anonymous, 13 years ago

Attachment: thread.diff added

by trueorca@…, 13 years ago

Attachment: locks.diff added

Egor Dmitrenkov

by trueorca@…, 13 years ago

Attachment: thread_heap_alloc.diff added

comment:1 by Egor Dmitrenkov <trueorca@…>, 13 years ago

attached patches solved the issue for me.

comment:2 by Egor Dmitrenkov <trueorca@…>, 13 years ago

Component: threadsthread

I guess "threads" conponent of the ticket actually should be "thread".

in reply to:  description comment:3 by mlrus@…, 12 years ago

Might be a boost bug "In fact it's try to bind the reference to an lvalue, which is invalid" according to Bugzilla Bug 43915

   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)

Replying to Sebastian Mingramm <s.mingramm@…>:

$ cat test.cpp 
#include <boost/thread.hpp>
int main() {}

$ g++ -v

Using built-in specs. COLLECT_GCC=g++ COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-pc-linux-gnu/4.5.0/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: ./configure --host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --disable-altivec --disable-fixed-point --with-ppl --with-cloog --disable-nls --with-system-zlib --disable-checking --disable-werror --enable-secureplt --enable-multilib --enable-libmudflap --disable-libssp --enable-libgomp --enable-cld --enable-languages=c,c++ --enable-shared --enable-threads=posix --enable-cxa_atexit --enable-clocale=gnu --enable-lto Thread model: posix gcc version 4.5.0 20100115 (experimental) (GCC)

$ g++ test.cpp -std=c++0x

In file included from /usr/include/boost/thread/thread.hpp:22:0,

from /usr/include/boost/thread.hpp:13, from test.cpp:1:

/usr/include/boost/thread/detail/thread.hpp: In function 'boost::thread&& boost::move(boost::thread&&)': /usr/include/boost/thread/detail/thread.hpp:349:16: error: invalid initialization of reference of type 'boost::thread&&' from expression of type 'boost::thread' In file included from /usr/include/boost/thread/detail/thread_heap_alloc.hpp:17:0,

from /usr/include/boost/thread/detail/thread.hpp:13, from /usr/include/boost/thread/thread.hpp:22, from /usr/include/boost/thread.hpp:13, from test.cpp:1:

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

from /usr/include/boost/thread/mutex.hpp:16, from /usr/include/boost/thread/pthread/thread_data.hpp:12, from /usr/include/boost/thread/thread.hpp:17, from /usr/include/boost/thread.hpp:13, from test.cpp:1:

/usr/include/boost/thread/locks.hpp: In member function 'boost::unique_lock<Mutex>& boost::unique_lock<Mutex>::operator=(boost::unique_lock<Mutex>&&) [with Mutex = boost::mutex, boost::unique_lock<Mutex> = boost::unique_lock<boost::mutex>]': /usr/include/boost/thread/future.hpp:414:91: instantiated from here /usr/include/boost/thread/locks.hpp:269:13: error: cannot bind 'boost::unique_lock<boost::mutex>' lvalue to 'boost::unique_lock<boost::mutex>&&' /usr/include/boost/thread/locks.hpp:279:14: error: initializing argument 1 of 'void boost::unique_lock<Mutex>::swap(boost::unique_lock<Mutex>&&) [with Mutex = boost::mutex, boost::unique_lock<Mutex> = boost::unique_lock<boost::mutex>]'

comment:4 by viboes, 12 years ago

Type: BugsPatches

comment:5 by anonymous, 12 years ago

Resolution: fixed
Status: newclosed

Already fixed on trunk

Note: See TracTickets for help on using tickets.