<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    From some review comments (reproduced below) it seems we're not
    entirely in agreement on the policy of handling precondition
    failures.<br>
    <br>
    I don't think my views are contentious, but before drafting a
    guideline I'd like to poll opinions.<br>
    <br>
    Essentially, if a precondition is violated then the code isn't
    responsible for doing anything in particular. It could hide the
    problem, it could detect and report the problem it could segfault.<br>
    <br>
    Clearly, if it is cheap to test an error condition then it can be
    worth doing so and reporting the problem. The meaning of "cheap" can
    be different between debug and release builds - so it sometimes
    makes sense to have something like assert/NDEBUG. In a lot of code
    it makes sense to have the check on even in release builds (this is
    true of a lot of the "assert" checks we have in initialization
    code).<br>
    <br>
    But detecting and reporting precondition failures is not something
    that code is responsible for, so I don't think we should have tests
    for it.<br>
    <br>
    Thoughts?<br>
    <br>
    ~~~~<br>
    <br>
    Extracts from:
    <a class="moz-txt-link-freetext" href="https://code.launchpad.net/~vanvugt/mir/saucy-build/+merge/169108">https://code.launchpad.net/~vanvugt/mir/saucy-build/+merge/169108</a><br>
    <br>
    <br>
    <blockquote type="cite">
      <pre wrap="">Instead of disabling the test I would propose replacing the assert() in the MirTestFramework contstructor with "if (...) abort()" as a temporary measure</pre>
    </blockquote>
    ....<br>
    <blockquote type="cite">
      <pre wrap="">/1/ A test represents a requirement on the behavior of code.

/2/ A precondition is something that code is allowed to assume (as it is the responsibility of the caller to ensure it holds).

/3/ The code has no responsibility to behave in a particular way if preconditions are violated. Its behavior is unspecified (or even undefined).

/4/ Tests that "preconditions violations" are reported correctly imply that they are not really preconditions - just conditions.

The point: <b class="moz-txt-star"><span class="moz-txt-tag">*</span>if<span class="moz-txt-tag">*</span></b> we want some preconditions to be conditions in debug builds, then it makes sense for the corresponding tests to be conditionally compiled.

Personally, I don't think these checks should ever be conditions <b class="moz-txt-star"><span class="moz-txt-tag">*</span>with tests to validate the behavior<span class="moz-txt-tag">*</span></b>. But unless there are performance reasons I feel that is is as important to aid problem diagnosis in release builds as in debug ones.</pre>
    </blockquote>
    ...
    <blockquote type="cite">
      <pre wrap="">If our error handling strategy depends on assert never being eliminated then that's obviously bad, but a discussion for elsewhere.</pre>
    </blockquote>
    <br>
    <br>
    <br>
  </body>
</html>