Skip to content

Instantly share code, notes, and snippets.

@kennethlakin
Last active December 16, 2015 21:08
Show Gist options
  • Save kennethlakin/5497027 to your computer and use it in GitHub Desktop.
Save kennethlakin/5497027 to your computer and use it in GitHub Desktop.
Clang++ get_future failure. Failure is also present in 3.2 and in SVN r180858:
$ ~/project/build/Debug+Asserts/bin/clang++ --version
clang version 3.3 (trunk 180858)
Target: x86_64-unknown-linux-gnu
Thread model: posix
$ ~/project/build/Debug+Asserts/bin/clang++ -pthread -Wall -pedantic -g -std=c++11 main.cpp && gdb -q ./a.out
Reading symbols from a.out...done.
(gdb) r
Starting program: a.out
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Program received signal SIGILL, Illegal instruction.
0x00000000004028f7 in std::__future_base::_State_base::_S_check<std::__future_base::_State_base> (__p=...) at /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../include/c++/4.7/future:463
463 __throw_future_error((int)future_errc::no_state);
(gdb) bt
#0 0x00000000004028f7 in std::__future_base::_State_base::_S_check<std::__future_base::_State_base> (__p=...) at /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../include/c++/4.7/future:463
#1 0x000000000040800e in std::__basic_future<int>::__basic_future (this=0x7fffffffdd08, __state=...) at /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../include/c++/4.7/future:613
#2 0x0000000000407fd8 in std::future<int>::future (this=0x7fffffffdd08, __state=...) at /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../include/c++/4.7/future:654
#3 0x0000000000407ded in std::future<int>::future (this=0x7fffffffdd08, __state=...) at /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../include/c++/4.7/future:654
#4 0x00000000004022b4 in std::packaged_task<int ()>::get_future() (this=0x7fffffffdd18) at /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../include/c++/4.7/future:1369
#5 0x0000000000401f01 in main () at main.cpp:10
(gdb) c
Continuing.
Program terminated with signal SIGILL, Illegal instruction.
The program no longer exists.
(gdb) quit
$ dmesg | tail -n 1
[11646.472941] traps: a.out[22074] trap invalid opcode ip:4027b7 sp:7fffb7e20870 error:0 in a.out[400000+f000]
$ uname -rv
3.8.0-19-generic #29-Ubuntu SMP Wed Apr 17 18:16:28 UTC 2013
#include <iostream>
#include <future>
using namespace std;
int fun() { return 1; }
int main()
{
std::packaged_task<int()> task(fun);
auto f=task.get_future();
std::thread t(std::move(task));
t.join();
std::cout<<f.get()<<std::endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment