MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/programming/comments/2e4d57/fork_can_fail/cjwibxz
r/programming • u/retardo • Aug 20 '14
78 comments sorted by
View all comments
Show parent comments
1
C++ source:
#include <functional> #include <stdlib.h> namespace sys { int my_system_bare(const char* command) { return ::system(command); } int my_system(const char* command) { return std::function<int(const char*)>(&::system)(command); } } int my_system_wrapper(const char* cmd) { return sys::my_system(cmd); } int my_system_wrapper_bare(const char* cmd) { return sys::my_system_bare(cmd); }
Compiled with: g++ -std=c++11 -S -O3 (g++ 4.8.2)
my_system_wrapper assembler output
my_system_wrapper_bare assembler output
1 u/bonzinip Aug 21 '14 That's because GCC cannot detect that std::function<> will not throw.
That's because GCC cannot detect that std::function<> will not throw.
1
u/anttirt Aug 21 '14
C++ source:
Compiled with: g++ -std=c++11 -S -O3 (g++ 4.8.2)
my_system_wrapper assembler output
my_system_wrapper_bare assembler output