TF_DISABLE_EXCEPTION_HANDLING does not disable all exceptions
pavanakumar opened this issue · comments
Pavanakumar Mohanamuraly commented
When compiling with -fno-exceptions
and explicitly specifying TF_DISABLE_EXCEPTION_HANDLING
before including the header even the simple example does not compile.
TF_DISABLE_EXCEPTION_HANDLING
#include <taskflow/taskflow.hpp>
int main(int nargs, char *args[]) {
tf::Executor executor;
tf::Taskflow taskflow("simple");
auto [A, B, C, D] = taskflow.emplace([]() { std::cout << "TaskA\n"; },
[]() { std::cout << "TaskB\n"; },
[]() { std::cout << "TaskC\n"; },
[]() { std::cout << "TaskD\n"; });
A.precede(B, C); // A runs before B and C
D.succeed(B, C); // D runs after B and C
executor.run(taskflow).wait();
return 0;
}
It looks like there are only two places that needs replacement (master
branch)
In file taskflow/core/error.h
line 20
template <typename... ArgsT>
//void throw_se(const char* fname, const size_t line, Error::Code c, ArgsT&&... args) {
void throw_re(const char* fname, const size_t line, ArgsT&&... args) {
std::ostringstream oss;
oss << "[" << fname << ":" << line << "] ";
//ostreamize(oss, std::forward<ArgsT>(args)...);
(oss << ... << args);
throw std::runtime_error(oss.str());
}
and in taskflow/utility/object_pool.hpp
line no 629
else {
//printf("create a new superblock\n");
_gheap.mutex.unlock();
f = 0;
//s = static_cast<Block*>(std::malloc(sizeof(Block)));
s = new Block();
if(s == nullptr) {
throw std::bad_alloc();
}
Once they are made to respect TF_DISABLE_EXCEPTION_HANDLING
the example compiles. Is it not possible to compile taskflow without exception safety?