You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@mxgrey: Just a side question: Does DART already make use of noexcept to distinguish code paths that never throw exceptions from ones that do?
It seems like that could make it clearer to end-users which DART functions have this guarantee and which don't, since you are right that many loading/visualization/debugging functions don't need it and could have very nice std::exceptions instead.
I don't know what the pros/cons are here though, just curious.
I agree that we should consider using noexcept for the benefit clarity and potential performance improvements. The catch (no pun intended) is that we do allow exceptions (in the form of assert) everywhere when DART is compiled in debug mode. The logic is that unwinding the stack is likely to be problematic when running a critical control loop, but it can be very useful when debugging errors.
Perhaps even more problematic is that applying the noexcept specifier to a function which calls any potentially-throwing functions will result in std::terminate if the noexcept function does not handle the exception itself. So if anything used inside of a DART noexcept function does throw an exception, then that DART function must handle the exception or else the entire program will be terminated.
I would like to be able to offer a guarantee to the user that DART functions will handle all possible internal exceptions in a reasonable way, but I think we would need to take some time to examine where all the potential exceptions could pop up inside of DART before we commit to applying the noexcept specifier anywhere.
Conclusion: I think if we have an opportunity to review the exception safety of DART in detail and can determine that using the noexcept specifier is safe, then we could use a macro which expands to noexcept in release mode while being blank in debug mode.
The text was updated successfully, but these errors were encountered:
I noted two options that might make this easier. You might already know about these:
There is a noexcept operator which performs a compile-time check whether an expression can produce an exception. We might be able to use this in DART unit tests to verify that certain components never throw exceptions. http://en.cppreference.com/w/cpp/language/noexcept
The noexcept specifier can optionally take an expression which evaluates to a boolean indicating whether or not the marked function should be noexcept. It seems like we could potentially simply pass the DART debug flag trivially as a constexpr instead of macroing it. http://en.cppreference.com/w/cpp/language/noexcept_spec
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions.
Discussion from #875:
@psigen: #875 (comment)
@mxgrey: #875 (comment)
The text was updated successfully, but these errors were encountered: