Parma Polyhedra Library requirements
C++ same-storage native integer product accumulation

C++ same-storage native integer product accumulation

UID:
VERSION:
CLASSIFICATION:
PREFIX:
Type
Level
MID
UID
REFS
Title
Statement
Rationale
Comment
BIBLIOGRAPHY
STATUS
COMPONENT
APPLICABILITY
VERIFICATION_METHODS
VERIFICATION_CRITERIA
SOURCE
LANGUAGE
VISIBILITY
INTERFACE
SW_SPEC
1
PPL-SPEC-000842
PPL-SPEC-000842
Native integer accumulated products and intermediate overflow

For the eleven native integer storage types and same-storage raw/checked forms in 🔗 1. Exact same-storage native integer arithmetic, entry values d, a and b shall denote the destination and two sources. When the product p = ab and complete expression are within the destination policy's finite interval, add_mul_assign_r shall assign d + p and sub_mul_assign_r shall assign d − p. They shall return V_EQ for each valid rounding request, including a strict relation flag.

When overflow checking is enabled and p is finite and representable, an unrepresentable final sum or difference shall have the range outcome of 🔗 4. Checked native arithmetic range outcomes. An unrepresentable product may cause an intermediate-overflow failure even if cancellation would bring the complete expression into range. V_UNKNOWN_NEG_OVERFLOW and V_UNKNOWN_POS_OVERFLOW shall identify the sign of that intermediate product overflow and promise no numeric answer. If the destination policy admits NaN, such a diagnostic shall leave its NaN representation; otherwise its payload shall be unspecified and reusable. No exactness, infinity or finite-result meaning shall be inferred from that payload.

An intermediate overflow may instead yield the range outcome of 🔗 4. Checked native arithmetic range outcomes when the complete expression is outside the finite interval. Every reported relation shall describe the complete expression's ordering relative to its reported computed value; an intermediate overflow shall not justify a false final-result relation. A successful finite answer shall equal the complete expression, including if an implementation recovers it after an intermediate range limit. No wider or fused accumulator shall be required.

With overflow checking disabled, both product and final expression shall be finite and representable. ROUND_NOT_NEEDED shall require those same two representability conditions. Entry values shall be finite for their own policies and lie in the destination policy's finite interval. The finite interval and raw destination policy shall follow 🔗 1. Exact same-storage native integer arithmetic.

The destination may be either source, the sources may share an object, and all arguments may be the same object. Each occurrence shall use its entry value, including the initial destination. Distinct sources shall remain unchanged. Calls shall require no rounding default or result handler and shall not invoke a handler. Live-object, synchronization, initialization and hardware-direction prerequisites shall follow 🔗 1. Exact same-storage native integer arithmetic. Configured coefficient convenience operations shall retain 🔗 6. Integral product accumulation and subtraction.

A bounded two-step accumulator has distinct product and final range limits. Intermediate failure can be reported honestly without confusing it with a proved bound on the complete expression.

APPROVED
NUMERICS
IF_CPP
Test, Analysis, Inspection

Use independent unbounded integer products and complete-expression oracles for all native storage types and reserved-value policies. Check exact products, final-only overflow, both product-overflow signs, cancellation, zero and nonzero destinations, all admitted requests and every alias pattern. Check that range relations apply to the complete expression, unknown diagnostics identify the product-overflow sign, distinct sources remain unchanged, no handler is invoked, outputs remain reusable and hardware direction is preserved without initialization.

src/Checked_Number_defs.hh; src/Checked_Number_inlines.hh; src/checked_int_inlines.hh; src/checked_ext_inlines.hh; tests/nativeintegeraccumulationspec1.cc.

CPP
Public

Public header: <ppl.hh>; effective instantiations in Parma_Polyhedra_Library for the admitted argument types:

Result add_mul_assign_r(To& to, const X& x, const Y& y,
                        Rounding_Dir dir);
Result sub_mul_assign_r(To& to, const X& x, const Y& y,
                        Rounding_Dir dir);