boost thread.hpp does not compile with -std=c++0x (Natty's gcc is not a supported compiler of Natty's boost)

Bug #776860 reported by Trent Apted
32
This bug affects 5 people
Affects Status Importance Assigned to Milestone
boost1.42 (Ubuntu)
Confirmed
Undecided
Unassigned

Bug Description

This is a regression from libboost1.40-dev in Lucid (gcc version 4.4.3), where this test works.

The version of gcc that ships with Natty is not a supported compiler of the boost that ships with Natty (see http://www.boost.org/users/history/version_1_42_0.html ).

boost started supporting gcc 4.5 series in v1.44, And the gcc 4.5.2 of natty is a "primary" test compiler since v1.46.

A newer boost package should be made available. 1.42 is from Feb,2010 -- 15 months old (see bug #754231).

Steps to reproduce:

$ cat test.cpp
#include <boost/thread.hpp>
$ g++ -std=c++0x -c test.cpp
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>]’

ProblemType: Bug
DistroRelease: Ubuntu 11.04
Package: libboost1.42-dev 1.42.0-4ubuntu2 [modified: usr/include/boost/config/compiler/gcc.hpp]
ProcVersionSignature: Ubuntu 2.6.38-8.42-generic 2.6.38.2
Uname: Linux 2.6.38-8-generic x86_64
Architecture: amd64
Date: Wed May 4 12:39:03 2011
ProcEnviron:
 LANGUAGE=en_AU:
 LANG=en_AU.UTF-8
 SHELL=/bin/bash
SourcePackage: boost1.42
UpgradeStatus: No upgrade log present (probably fresh install)

Revision history for this message
Trent Apted (tapted) wrote :
Revision history for this message
Trent Apted (tapted) wrote :

oh, regarding:
Package: libboost1.42-dev 1.42.0-4ubuntu2 [modified: usr/include/boost/config/compiler/gcc.hpp]

*After* generating the compile error, I commented out `# define BOOST_HAS_RVALUE_REFS` in

#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 2)) && defined(__GXX_EXPERIMENTAL_CXX0X__)
// C++0x features are only enabled when -std=c++0x or -std=gnu++0x are
// passed on the command line, which in turn defines
// __GXX_EXPERIMENTAL_CXX0X__.
# define BOOST_HAS_DECLTYPE
//# define BOOST_HAS_RVALUE_REFS
# define BOOST_HAS_STATIC_ASSERT
# define BOOST_HAS_VARIADIC_TMPL
#else

With this change, test.cpp compiles.

Sadly, there's no compile flag I can pass in along with `-std=c++0x` to achieve a similar effect (i.e. without editing gcc.hpp).

Changed in boost1.42 (Ubuntu):
status: New → Confirmed
Revision history for this message
Dennis Schridde (devurandom) wrote : apport information

Architecture: i386
DistroRelease: Ubuntu 11.04
InstallationMedia: Kubuntu-Netbook 10.04 "Lucid Lynx" - Beta i386 (20100318)
Package: libboost-dev 1.42.0.1ubuntu1
PackageArchitecture: i386
ProcEnviron:
 PATH=(custom, no user)
 SHELL=/bin/bash
ProcVersionSignature: Ubuntu 2.6.38-10.46-generic 2.6.38.7
Tags: natty
Uname: Linux 2.6.38-10-generic i686
UpgradeStatus: Upgraded to natty on 2011-04-28 (85 days ago)
UserGroups: adm admin cdrom dialout fuse lpadmin netdev plugdev sambashare

tags: added: apport-collected
Revision history for this message
Dennis Schridde (devurandom) wrote : Dependencies.txt

apport information

Revision history for this message
Dennis Schridde (devurandom) wrote :

Confirming that the workaround from comment #2 makes my application compile, which previously failed with:
/usr/include/boost/thread/detail/thread.hpp:349:16: error: invalid initialization of reference of type 'boost::thread&&' from expression of type 'boost::thread'

Revision history for this message
BaCh (bach) wrote :

I am running Kubuntu 11.10 and that bug is still present. I see the importance still set to "Undecided".

May I suggest to set it to a quite high level? C++11 is now officially through, having "-std=c++0x" or "-std=c++11" is getting more and more common, having GCC fail on BOOST on recent *buntu platforms is not good.

The workaround will work, but many users who just want to "./configure; make" a package will shy off performing the edits (even if they have the rights).

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.