#4396 closed Bugs (fixed)
thread does not compile with gcc 4.5 and -std=gnu++0x
| Reported by: | Owned by: | Anthony Williams | |
|---|---|---|---|
| Milestone: | Boost 1.44.0 | Component: | thread |
| Version: | Boost 1.42.0 | Severity: | Showstopper |
| Keywords: | Cc: |
Description
the easiest way to see the problem is
cp boost-1_42/boost/thread.hpp . c++ -pthread -O2 -Iboost-1_42/ -std=gnu++0x thread.hpp In file included from boost-1_42/boost/thread/thread.hpp:22:0,
from thread.hpp:13:
boost-1_42/boost/thread/detail/thread.hpp: In function 'boost::thread&& boost::move(boost::thread&&)': boost-1_42/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 boost-1_42/boost/thread/detail/thread_heap_alloc.hpp:17:0,
from boost-1_42/boost/thread/detail/thread.hpp:13, from boost-1_42/boost/thread/thread.hpp:22, from thread.hpp:13:
boost-1_42/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-1_42/boost/thread/detail/thread.hpp:130:95: instantiated from here boost-1_42/boost/thread/pthread/thread_heap_alloc.hpp:24:47: error: cannot bind 'void (*)()' lvalue to 'void (*&&)()' boost-1_42/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 boost-1_42/boost/thread/pthread/mutex.hpp:11:0,
from boost-1_42/boost/thread/mutex.hpp:16, from boost-1_42/boost/thread/pthread/thread_data.hpp:12, from boost-1_42/boost/thread/thread.hpp:17, from thread.hpp:13:
boost-1_42/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>]': boost-1_42/boost/thread/future.hpp:414:91: instantiated from here boost-1_42/boost/thread/locks.hpp:269:13: error: cannot bind 'boost::unique_lock<boost::mutex>' lvalue to 'boost::unique_lock<boost::mutex>&&' boost-1_42/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>]'
c++ being either GNU C++ (GCC) version 4.5.0 (x86_64-unknown-linux-gnu)
compiled by GNU C version 4.5.0, GMP version 4.3.2, MPFR version 2.4.2, MPC version 0.8.1
or GNU C++ (GCC) version 4.6.0 20100408 (experimental) (x86_64-unknown-linux-gnu)
compiled by GNU C version 4.6.0 20100408 (experimental), GMP version 4.3.2, MPFR version 2.4.2, MPC version 0.8.1
Change History (6)
comment:1 by , 12 years ago
| Component: | None → thread |
|---|---|
| Owner: | set to |
comment:2 by , 12 years ago
comment:3 by , 12 years ago
| Resolution: | → fixed |
|---|---|
| Status: | new → closed |
Trunk compiles with gcc 4.5 in -std=c++0x mode.
comment:4 by , 12 years ago
i cannot confirm that.
also with trunk, revision 63919 i get the above error with gcc 4.5
comment:5 by , 12 years ago
Clarification: Boost.Thread on trunk (revision 63919) compiles with gcc 4.5 in -std=c++0x mode (tested on Ubuntu 9.10/x86_64 with gcc-4.5 (Ubuntu 4.5-20100227-1gezakovacs~karmic1) 4.5.0 20100227 (experimental) [trunk revision 157109])
comment:6 by , 12 years ago
i filed a new ticket ( #4426 ) for component interprocess
what commit fixed the problem for boost.thread ?

it is not only in the thread library, the boost/interprocess library has a similar error (invalid initialization of reference type)
this code builds fine with msvc2010
with gcc 4.6 beta i get the same error.
without the -std=c++0x option it compiles ok
with boost_1_40_0 and boost_1_39_0 i also get the same error.
echo '#include "boost/interprocess/file_mapping.hpp"' > xinc.cpp g++-mp-4.5 -I /opt/local/include/ xinc.cpp -std=c++0x In file included from /opt/local/include/boost/interprocess/detail/utilities.hpp:25:0, from /opt/local/include/boost/interprocess/file_mapping.hpp:19, from xinc.cpp:1: /opt/local/include/boost/interprocess/detail/move.hpp: In function 'typename boost::remove_reference<T>::type&& boost::interprocess::move(T&&) [with T = boost::interprocess::file_mapping&, typename boost::remove_reference<T>::type = boost::interprocess::file_mapping]': /opt/local/include/boost/interprocess/file_mapping.hpp:62:55: instantiated from here /opt/local/include/boost/interprocess/detail/move.hpp:342:11: error: invalid initialization of reference of type 'boost::remove_reference<boost::interprocess::file_mapping&>::type&&' from expression of type 'boost::interprocess::file_mapping'