Parma Polyhedra Library requirements
C++ assertion and diagnostic helpers
PPL-SPEC-001590
1. Fatal unreachable and assertion diagnostics UID: PPL-SPEC-001590 STATUS: APPROVED COMPONENT: RUNTIME APPLICABILITY: IF_CPP VERIFICATION_METHODS: Test, Analysis, Inspection LANGUAGE: CPP VISIBILITY: Internal RELATIONS (Parent): STATEMENT:

The default library definitions of ppl_unreachable, ppl_unreachable_msg and ppl_assertion_failed shall call abort and shall not return. With ordinary functioning diagnostic output, ppl_unreachable_msg shall first write to std::cerr the file, line, function and supplied latent-fault message; ppl_assertion_failed shall write the same location plus the supplied failed-assertion text. The message-free helper shall add no diagnostic output. Non-null live null-terminated text arguments shall be required. Diagnostic stream failures shall retain the stream's ordinary failure/exception behavior; output failure shall not be interpreted as successful continuation.

Where the build supports weak replacement of these definitions, a client replacement shall retain the declared nonreturning interface and own its replacement behavior. The default abort behavior shall apply when no such replacement is linked.

RATIONALE:

A violated internal invariant needs a terminating diagnostic path rather than a numerical result that could be mistaken for successful computation.

INTERFACE:

Public header: <ppl.hh>; implementation names in Parma_Polyhedra_Library. Member excerpts apply to the indicated types.

[[noreturn]] void ppl_unreachable();
[[noreturn]] void ppl_unreachable_msg(
    const char* msg, const char* file, unsigned int line,
    const char* function);
[[noreturn]] void ppl_assertion_failed(
    const char* assertion_text, const char* file, unsigned int line,
    const char* function);
VERIFICATION_CRITERIA:

In isolated processes, check SIGABRT and exact diagnostic text for each default helper, including the silent helper. Distinguish return, exceptions and unrelated signals from the required abort; disable core-file creation.

SOURCE:

src/assertions.hh; src/assertions.cc; tests/assertionsspec1.cc; tests/assertionmacroexpressionspec1.cc.

PPL-SPEC-001591
2. Enabled and disabled assertion evaluation UID: PPL-SPEC-001591 STATUS: APPROVED COMPONENT: RUNTIME APPLICABILITY: IF_CPP VERIFICATION_METHODS: Test, Analysis, Inspection LANGUAGE: CPP VISIBILITY: Internal RELATIONS (Parent): STATEMENT:

With NDEBUG absent, PPL_ASSERT(cond) and PPL_EXPECT(cond) shall evaluate the condition once and invoke the assertion-failure diagnostic when false. An ordinary assertion shall preserve computational weight; the additional weight check enabled by PPL_DEBUG_PPL_ASSERT shall diagnose a weight-changing condition. PPL_ASSERT_HEAVY and PPL_EXPECT_HEAVY shall evaluate their condition once under the assertion weight guard, suppressing instrumentation weight additions according to 🔗 6. Assertion-scope instrumentation suppression. A true assertion shall continue normally. A thrown condition exception shall propagate, with the heavy guard's assertion-state restoration on scope exit. Direct mutations of the weight variable shall retain their ordinary effects; the guard shall not provide numerical rollback.

With NDEBUG defined, all four macros shall omit condition evaluation, including its side effects. Macro use shall provide a condition meaningful in an enabled build and satisfy the shared-weight synchronization conditions of the selected runtime profile.

RATIONALE:

Debug checks must have controlled evaluation and weight effects, and their removal must not be relied on to perform required production work.

INTERFACE:

Public header: <ppl.hh>; implementation names in Parma_Polyhedra_Library. Member excerpts apply to the indicated types.

PPL_ASSERT(cond);
PPL_ASSERT_HEAVY(cond);
PPL_EXPECT(cond);
PPL_EXPECT_HEAVY(cond);
VERIFICATION_CRITERIA:

Compile enabled and NDEBUG clients. Count condition evaluations, check ordinary/heavy weight effects and exception restoration, and check failure diagnostics in isolated processes without changing the library configuration.

SOURCE:

src/assertions.hh; src/assertions.cc; tests/assertionsspec1.cc; tests/assertionmacroexpressionspec1.cc.

PPL-SPEC-001592
3. Unreachable macro diagnostic selection UID: PPL-SPEC-001592 STATUS: APPROVED COMPONENT: RUNTIME APPLICABILITY: IF_CPP VERIFICATION_METHODS: Test, Analysis, Inspection LANGUAGE: CPP VISIBILITY: Internal RELATIONS (Parent): STATEMENT:

PPL_UNREACHABLE_MSG(msg) shall invoke the message-bearing unreachable helper when NDEBUG is absent, supplying the macro invocation's file, line and function. With NDEBUG defined, it shall invoke the message-free helper and shall not evaluate the message expression. PPL_UNREACHABLE shall supply the literal message unreachable in an enabled build. Neither macro shall continue through the default helper. The helper and client-replacement conditions of 🔗 1. Fatal unreachable and assertion diagnostics shall apply.

RATIONALE:

The unreachable marker retains fail-fast behavior in optimized builds while allowing debug builds to identify the failed internal assumption.

INTERFACE:

Public header: <ppl.hh>; implementation names in Parma_Polyhedra_Library. Member excerpts apply to the indicated types.

PPL_UNREACHABLE_MSG(msg);
PPL_UNREACHABLE;
VERIFICATION_CRITERIA:

Use isolated enabled and NDEBUG clients to check abort behavior, invocation location and exact debug message; verify message-expression side effects occur only in the enabled form.

SOURCE:

src/assertions.hh; src/assertions.cc; tests/assertionsspec1.cc; tests/assertionmacroexpressionspec1.cc.

PPL-SPEC-001593
4. Containment queries on independent value copies UID: PPL-SPEC-001593 STATUS: APPROVED COMPONENT: RUNTIME APPLICABILITY: IF_CPP VERIFICATION_METHODS: Test, Analysis, Inspection LANGUAGE: CPP VISIBILITY: Internal RELATIONS (Parent): STATEMENT:

copy_contains(x,y) shall invoke contains on its by-value argument copies and return that query's Boolean result. The type shall provide value copies on which contains can operate without mutating either original or shared caller-owned storage. Under that precondition, the helper shall preserve the two original objects, including mutable representation caches. The type's copying and containment contracts shall otherwise apply. Copy or query exceptions may propagate; argument-copy resources shall be released during normal completion and unwinding. The template shall require valid copyable argument values and the corresponding contains operation, plus the type's initialization, numerical and synchronization prerequisites.

RATIONALE:

Checking containment inside an assertion must not normalize or otherwise change the original values through logically const cache updates.

INTERFACE:

Public header: <ppl.hh>; implementation names in Parma_Polyhedra_Library. Member excerpts apply to the indicated types.

template <typename T>
bool copy_contains(T x_copy, T y_copy);
VERIFICATION_CRITERIA:

Check contained and noncontained polyhedra against independent geometry; compare both original serialized states before and after the copy query. Use a recording value type to check copy/query exception identity and resource release without mutation of either original.

SOURCE:

src/assertions.hh; src/assertions.cc; tests/assertionsspec1.cc; tests/assertionmacroexpressionspec1.cc.