TYCHO Search

Search documentation

    ↑ ↓ to move · Enter to open · Esc to close

    30. Defined runtime behavior and failure

    This chapter defines what happens at run time for the conditions a program can reach: which wrap (defined), which abort cleanly, which clamp, and the small register of conditions left unspecified. Tycho's guiding principle is to fail closed — a doubtful operation aborts cleanly rather than proceeding into undefined behavior — and the unspecified register is kept minimal, consistent with the abstract-exact policy (§1.1).

    An abort terminates the program with a non-zero exit status after writing a diagnostic to standard error. The *presence* of the abort is normative; the diagnostic text is not (§1.1).

    30.1 Defined wraparound

    Integer overflow and an over-wide shift count (≥ the operand's bit width, defined as 0) are the arithmetic conditions that are fully defined rather than aborting; every other numeric edge either aborts (§30.2 — including a negative shift count, an out-of-range chr, and an out-of-range to_int(float)) or is unspecified (§30.5).

    30.2 Conditions that abort

    A conforming implementation MUST abort on each of the following:

    30.3 Conditions that clamp

    30.4 Defined string and map behavior

    30.5 Unspecified behavior

    The following are unspecified: this specification imposes no requirement, and a conforming program MUST NOT depend on them. They are collected in Appendix F.

    Aside from this register, Tycho has essentially no implementation-defined or undefined behavior: value semantics removes the aliasing UB of pointer languages, defined integer wrap removes overflow UB, and the fail-closed aborts of §30.2 convert the remaining partial operations into clean termination.