erik.pilkington added a comment. JF, Michael, and I were talking about this offline, and we think that the right choice of semantics for the static local case is to call the destructors.
struct HoldsResource { HoldsResource() { tryToAcquireItMayThrow(); } ~HoldsResource() { releaseIt(); } }; void doSomeThings() { try { [[clang::no_destroy]] static HoldsResource MyResources[10]; } catch (...) { /* recover gracefully somehow.... */ } } Here, its possible to call `doSomeThings` many times, until it actually manages to construct `MyResources`. Just not calling the dtor doesn't seem right since we'd be leaking resources. Calling `terminate` doesn't make sense either, since its possible to recover from this and try again or continue. `no_destroy` doesn't mean don't destroy (lol), it means don't register exit-time dtors, that's why it only applies to static/thread local declarations. @rjmccall: WDYT? This is obviously a pretty narrow edge-case. Repository: rC Clang CHANGES SINCE LAST ACTION https://reviews.llvm.org/D61165/new/ https://reviews.llvm.org/D61165 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits