Opened 12 years ago

Closed 10 years ago

#5040 closed Bugs (fixed)

future.hpp in boost::thread does not compile with /clr

Reported by: Colin Powers <colin.powers@…> Owned by: viboes
Milestone: Boost 1.52.0 Component: thread
Version: Boost 1.45.0 Severity: Problem
Keywords: MANAGED Cc: viboes

Description

Including thread.hpp in a project using the /clr compiler flag results in the following output.

[...]\boost-1.45\include\boost-1_45\boost/thread/future.hpp(422) : error C2666: 'boost::scoped_array<T>:
:operator []' : 2 overloads have similar conversions
        with
        [
            T=boost::unique_lock<boost::mutex>
        ]
        [...]\boost-1.45\include\boost-1_45\boost/smart_ptr/scoped_array.hpp(77): could be 'boost::uniqu
e_lock<Mutex> &boost::scoped_array<T>::operator [](ptrdiff_t) const'
        with
        [
            Mutex=boost::mutex,
            T=boost::unique_lock<boost::mutex>
        ]
        or 'built-in C++ operator[(void (__cdecl *)(boost::scoped_array<T> ***), boost::detail::future_waiter::count_typ
e)'
        with
        [
            T=boost::unique_lock<boost::mutex>
        ]
        while trying to match the argument list '(boost::scoped_array<T>, boost::detail::future_waiter::count_type)'
        with
        [
            T=boost::unique_lock<boost::mutex>
        ]
[...]\boost-1.45\include\boost-1_45\boost/thread/future.hpp(435) : error C2666: 'boost::scoped_array<T>:
:operator []' : 2 overloads have similar conversions
        with
        [
            T=boost::unique_lock<boost::mutex>
        ]
        [...]\boost-1.45\include\boost-1_45\boost/smart_ptr/scoped_array.hpp(77): could be 'boost::uniqu
e_lock<Mutex> &boost::scoped_array<T>::operator [](ptrdiff_t) const'
        with
        [
            Mutex=boost::mutex,
            T=boost::unique_lock<boost::mutex>
        ]
        or 'built-in C++ operator[(void (__cdecl *)(boost::scoped_array<T> ***), boost::detail::future_waiter::count_typ
e)'
        with
        [
            T=boost::unique_lock<boost::mutex>
        ]
        while trying to match the argument list '(boost::scoped_array<T>, boost::detail::future_waiter::count_type)'
        with
        [
            T=boost::unique_lock<boost::mutex>
        ]
[...]\boost-1.45\include\boost-1_45\boost/thread/future.hpp(435) : error C2228: left of '.unlock' must h
ave class/struct/union

I couldn't find any tickets on this problem however a quick google brought up someone who has encountered this before: http://groups.google.com/group/boost-list/browse_thread/thread/9662c882efc153b6?pli=1

unsigned should probably convert to ptrdiff_t implicitly but it's throwing a wobbly with /clr. Maybe this is fair enough as specifying /clr opens a whole new world of pain (I was just trying my luck really!), nevertheless would it be sensible to change the types from unsigned to ptrdiff_t as that's what operator[] requires?

Attachments (1)

5040.patch (1.3 KB ) - added by viboes 11 years ago.

Download all attachments as: .zip

Change History (14)

comment:1 by viboes, 11 years ago

Cc: viboes added

Currently the type is defined as

typedef std::vector<registered_waiter>::size_type count_type;

Please could you verify which types is this on your platform?

Could you try changing

for(count_type i=0;i<count;++i)

by

for(std::ptrdiff_t i=0;i<count;++i)

to see if the patch solve the issue?

comment:2 by colin.powers@…, 11 years ago

typedef std::vector<registered_waiter>::size_type count_type;

takes me to this definition:

typedef typename _Alloc::size_type size_type;

However I'm not sure how much further I can dig there.

Altering the for loops as you suggested on lines 420 and 433, along with altering the type of count on line 414 to be std::ptrdiff_t as well, gets rid of the errors. count had to change type to avoid signed/unsigned errors.

I can then compile but get the following warning which causes an error at runtime:

warning LNK4248: unresolved typeref token (0100001E) for 'boost.detail.win32._SECURITY_ATTRIBUTES'; image may not run

However I imagine this is a separate issue and therefore not relevant to this ticket.

in reply to:  1 comment:3 by Colin Powers <colin.powers@…>, 11 years ago

Apologies I appear to have missed the Reply button initially. Please see the comment below for my response.

Replying to viboes:

Currently the type is defined as

typedef std::vector<registered_waiter>::size_type count_type;

Please could you verify which types is this on your platform?

Could you try changing

for(count_type i=0;i<count;++i)

by

for(std::ptrdiff_t i=0;i<count;++i)

to see if the patch solve the issue?

comment:4 by viboes, 11 years ago

Cc: viboes removed
Owner: changed from Anthony Williams to viboes
Status: newassigned

by viboes, 11 years ago

Attachment: 5040.patch added

comment:5 by viboes, 11 years ago

Could you check this patch?

comment:6 by viboes, 11 years ago

Cc: viboes added
Keywords: MANAGED added
Milestone: To Be DeterminedBoost 1.49.0

Committed in trunk #75901

comment:7 by viboes, 11 years ago

Resolution: fixed
Status: assignedclosed

(In [76346]) Thread: merge from trunk to fix #6141, #5594, #5040 and #5502.

comment:8 by anonymous, 10 years ago

This patch was overwritten again in trunk (and versions 1.49, 1.50) by svn change #76543. Please reapply it.

comment:9 by moala@…, 10 years ago

Resolution: fixed
Status: closedreopened

I reopen it due to last comment and encountered bug.

comment:10 by moala@…, 10 years ago

(still buggy in 1.51.0)

comment:11 by viboes, 10 years ago

Milestone: Boost 1.49.0Boost 1.52.0

Sorry for the disturbance. I will apply it today.

comment:12 by viboes, 10 years ago

Committed in trunk revision [81032][81034].

comment:13 by viboes, 10 years ago

Resolution: fixed
Status: reopenedclosed

Committed revision [81035].

Note: See TracTickets for help on using tickets.