#include <exception>
struct FOO
{
~FOO() try
{
throw std::exception();
}
catch (...)
{
return; // Shall prevent the exception from being rethrown?
}
};
Building this code in Visual Studio triggers C4297 warning (function assumed not to throw an exception but does).
Reaching the end of a catch clause for a function-try-block on a destructor also automatically rethrows the current exception as if by throw;, but a return statement is allowed. quoted from cppreference.com;
Do I interpret this sentence correctly? Does return from the catch statement shall prevent the exception from being rethrown?
I logged a bug but they closed it as duplicate. The other bug does not have a return statement
but I think it makes all the difference.