Hi,
I'm having some trouble using floating point exceptions (FPE) with TBB in release mode. Basically when an FPE happens I want my program to show the windows crash dialog with the option to attach a debugger. This works fine for programs compiled in debug mode for FPE both inside and outside TBB algorithms. For release mode builds FPE outside TBB algorithms also produce the desired crash, but for FPE inside TBB the error is translated into a C++ exception, which seems inconsistent.
So:
debug mode + outside parallel_for: crash dialog
debug mode + inside parallel_for: crash dialog
release mode + outside parallel_for: crash dialog
release mode + inside parallel_for: unknown exception thrown!
How do I avoid TBB translating my FPE to a C++ exception?
Kind regards
Anders
extern float bar = -1.f;
int main(int argc, char* argv[])
{
_MM_SET_EXCEPTION_MASK(_MM_GET_EXCEPTION_MASK()
& ~(_MM_MASK_INVALID|
_MM_MASK_OVERFLOW |
_MM_MASK_DIV_ZERO));
tbb::task_scheduler_init tsi;
std::vector<float> foo(16);
//make FPE outside TBB
//foo[0] = std::sqrt(bar);
try {
tbb::parallel_for(
tbb::blocked_range<size_t>(0, foo.size()),
[&](const tbb::blocked_range<size_t>& range) {
std::printf("beforen");
for (auto i=range.begin(); i!=range.end(); ++i)
{
std::printf("%in", int(i));
foo[i] = std::sqrt(float(i));
//make FPE inside TBB algorithm
if (i==15)
foo[i] = std::sqrt(bar);
}
std::printf("aftern");
}, tbb::auto_partitioner());
}catch (std::exception& e)
{
std::printf("exception: %sn", e.what());
}
return 0;
}



