This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: c++11 / unique_ptr with packaged_task


On Fri, Mar 1, 2013 at 12:45 AM, Jonathan Wakely <jwakely.gcc@gmail.com> wrote:
> On 1 March 2013 10:35, Jonathan Wakely wrote:
>> On 1 March 2013 06:21, NightStrike wrote:
>>> This code compiles with clang/libc++, but doesn't with gcc4.8/libstdc++:
>>>
>>> #include <functional>
>>> #include <future>
>>> #include <iostream>
>>> #include <memory>
>>> #include <ostream>
>>>
>>> struct S
>>> {
>>>         void f()
>>>         {
>>>                 std::cerr << "Meep meep\n";
>>>         }
>>> };
>>>
>>> int main()
>>> {
>>>         std::unique_ptr<S> sp(new S);
>>>         std::packaged_task<void ()> pt(std::bind(&S::f, std::move(sp)));
>>>         pt();
>>>         std::cerr << "sp is empty: " << std::boolalpha << !sp << std::endl;
>>> }
>>>
>>>
>>>
>>> Is that a bug in gcc?
>>
>> The problem is that I implemented packaged_task using a std::function
>> to hold the stored task, and std::function requires a
>> CopyConstructible target object, but your function object is only
>> MoveConstructible.
>>
>> This is a GCC bug, I think I can see an easy way to fix it, but it
>> will have to wait for 4.8.1 because it's not a regression.
>
> This is now http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56492

Thanks for the quick response on this!  I'll watch the bug so I can
put the fix in my local toolchain as soon as it's available.  Do you
think you'll have something sooner rather than later, even if it won't
be in a release?


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]