Modify

Opened 7 years ago

Closed 7 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: anthonyw
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 7 years ago.
locks.diff (410 bytes) - added by trueorca@… 7 years ago.
Egor Dmitrenkov
thread_heap_alloc.diff (530 bytes) - added by trueorca@… 7 years ago.

Download all attachments as: .zip

Change History (8)

Changed 7 years ago by anonymous

Changed 7 years ago by trueorca@…

Egor Dmitrenkov

Changed 7 years ago by trueorca@…

comment:1 Changed 7 years ago by Egor Dmitrenkov <trueorca@…>

attached patches solved the issue for me.

comment:2 Changed 7 years ago by Egor Dmitrenkov <trueorca@…>

  • Component changed from threads to thread

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

comment:3 in reply to: ↑ description Changed 7 years ago by mlrus@…

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 Changed 7 years ago by viboes

  • Type changed from Bugs to Patches

comment:5 Changed 7 years ago by anonymous

  • Resolution set to fixed
  • Status changed from new to closed

Already fixed on trunk

Add Comment

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain anthonyw.
The resolution will be deleted. Next status will be 'reopened'.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.