-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Description
There have been discussions recently in #1512 and microsoft/GSL#831 regarding contract violation behavior. Would the editors mind clarifying the desired behavior for contract violation and updating GSL.assert as necessary?
The confusion stems from a potential contradiction between an Editor's call in issue #1512 and a note in the GSL.Assert section for Expects.
Editors' call: GSL.assert currently requires Expects to terminate the program if the condition is false. This is intended to mean std::terminate which permits a terminate_handler to do things like log some final information before restarting the process to try again. There is nothing in the Guidelines today about Expects throwing on contract violations.
Clarification: Expects should terminate, not abort, just to be clear.
Note from the Expects section of GSL.Assert:
// Expect in under control of some options (enforcement, error message, alternatives to terminate)
Microsoft's GSL implementation removed the alternative violation behaviors (throwing & unenforced) with PR microsoft/GSL#831. This change also had the side benefit of preventing potential ODR violations from misconfiguring contract violation behaviors.