Bug 59830 - std::packaged_task throws exception
Summary: std::packaged_task throws exception
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: libstdc++ (show other bugs)
Version: 4.7.2
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-01-15 15:55 UTC by b17c0de
Modified: 2014-01-16 11:58 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description b17c0de 2014-01-15 15:55:43 UTC
user@domain:~/work/test$ uname -a
Linux domain 3.2.0-4-amd64 #1 SMP Debian 3.2.51-1 x86_64 GNU/Linux

user@domain:~/work/test$ g++ --version
g++ (Debian 4.7.2-5) 4.7.2
Copyright (C) 2012 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

user@domain:~/work/test$ cat fut.cc 
#include <iostream>
#include <future>

int main()
{
  std::packaged_task<int()> task([]() { return 42; });
  std::future<int> result = task.get_future();
  task();
  std::cout << "task_lambda:\t" << result.get() << '\n';
}

user@domain:~/work/test$ g++ -std=c++11 -g fut.cc
user@domain:~/work/test$ ./a.out 
terminate called after throwing an instance of 'std::system_error'
  what():  Unknown error 18446744073709551615
Abgebrochen
Comment 1 Jonathan Wakely 2014-01-15 16:14:59 UTC
<future> relies on mutexes and condition variables so you need to compile and link with -pthread
Comment 2 b17c0de 2014-01-16 08:42:25 UTC
(In reply to Jonathan Wakely from comment #1)
> <future> relies on mutexes and condition variables so you need to compile
> and link with -pthread

Thanks! That was indeed the problem. Whats with the strange error though?
Comment 3 Jonathan Wakely 2014-01-16 11:58:26 UTC
It should print the error code returned by the underlying pthread_once() call, which is -1

I don't know why it's printing (unsigned long)-1 instead.