It looks like if an unhandled exception makes it all the way up to main, the destructor of ScopeGuard is not called.
Nevertheless, the documentation seems to promise exactly that.
ScopeGuard is a class which ensure thats Kokkos::initialize and Kokkos::finalize are called correctly even in the presence of unhandled exceptions.
It looks like if an unhandled exception makes it all the way up to
main
, the destructor ofScopeGuard
is not called. Nevertheless, the documentation seems to promise exactly that.But if the exception reaches
main
it seems to cause immediate termination of the program: https://godbolt.org/z/Pahs8MW3GFurthermore, creating an unnamed
ScopeGuard
allows the compiler to callfinalize
immediately afterinitialize
;