openMP loop and exception
-
Hi all, I have a for loop parallelized with openMP. Inside I want to catch possible exceptions. My idea is that the caught exception should be a private variable, as it is possible that several exception occur parallel. But I cannot express this. example:
#pragma omp parallel for default(none)
for ( int i = 0; i < 10; ++ i )
{
try
{
// do something ...
}
catch ( const std::exception& e )
{
e;
// handle exception ...
}
}This yields to compiler error:
error C3052: 'e' : variable doesn't appear in a data-sharing clause under a default(none) clause
But I cannot mark the exception variable as private, as I is not known at that scope.
I can bypass the compiler error by changing the default sharing behaviour to shared, but I think this could lead to a runtime error, if two exceptions occur at the same time.
What is the correct way to deal with this?
Thanks in advance, Joerg