Native coefficient lifetime and scalar support adapters
|
Type
|
Level
|
MID
|
UID
|
REFS
|
Title
|
Statement
|
Rationale
|
Comment
|
BIBLIOGRAPHY
|
STATUS
|
COMPONENT
|
APPLICABILITY
|
VERIFICATION_METHODS
|
VERIFICATION_CRITERIA
|
SOURCE
|
LANGUAGE
|
VISIBILITY
|
INTERFACE
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
SW_SPEC
|
1 |
|
|
Incoming link from:
2. Consuming coefficient relocation
1 |
For an admitted native integral storage type T, move construction of Checked_Number<T, Policy> shall copy the source's stored integer value and preserve the source. It shall be a trivial, nonthrowing constructor and shall invoke neither a conversion operation nor Policy::handle_result. The wrapper shall have a trivial destructor and one native integral data member; it shall be an implicit-lifetime class under C++20. Its size and alignment shall equal those of T. These properties shall not imply that the wrapper is trivially copyable. The copy constructor and copy assignment shall retain their separately specified behavior. This constructor shall be available only when Is_Native<T>::value is nonzero and std::is_integral_v<T> is true. GMP and floating-point storage shall retain the existing copy-from-rvalue behavior. The source shall be a live initialized object with an admitted stored representation; no library initialization, rounding setup, allocation or policy callback shall be required. |
A trivial eligible constructor and trivial destructor admit implicit lifetime creation for the native-integer wrapper while preserving policy-aware copies for other storage types. |
|
|
|
|
|
Check trivial/nothrow move, trivial destruction, nontrivial copy, layout and size/alignment traits for every admitted native integral type; exercise zero, one and both range extrema with source preservation and a counting policy. Check independent GMP copies from rvalues and exclusion of floating storage. Inspect the C++20 lifetime argument separately from execution tests. |
src/Checked_Number_defs.hh; src/Checked_Number_inlines.hh; tests/checkedmovespec1.cc; tests/scalaradapterspreinit1.cc. |
|
|
Names belong to Parma_Polyhedra_Library unless qualified otherwise. Template excerpts omit SFINAE return-type restrictions described in the text. // Member of Checked_Number<T, Policy>: Checked_Number(Checked_Number&&) requires (Is_Native<T>::value != 0 && std::is_integral_v<T>) = default; |
||
|
SW_SPEC
|
2 |
|
|
|
For the configured coefficient type, relocate_coefficient(to,from) shall transfer the entry source value to a distinct destination slot. relocate_coefficients(to,from,count) shall transfer the ordered sequence of count source values between disjoint ranges. relocate_coefficients_right(from,count,shift) shall transfer that sequence to the range beginning shift slots later in the same allocation; overlapping, touching and disjoint ranges, zero count and zero shift shall be admitted. Overlap shall preserve the entry sequence, as if its values were first retained before writing the destination. Source slots shall contain live initialized coefficients. Destination-only slots shall be suitably aligned uninitialized or previously consumed storage. All pointers shall designate valid storage even when count is zero; the source and destination extents and byte-size products shall be representable and fit their allocations. After relocation the destination range shall hold live coefficients with the entry source values and ownership. Source-only slots shall be consumed: their old values shall neither be accessed nor destroyed; they may be reconstructed or their storage released without coefficient destruction. Overlap slots belonging to the destination shall remain live. No coefficient-owned resource shall be duplicated or lost. The helpers shall be nonthrowing, allocate no storage and invoke no numerical conversion, policy handler or rounding control. They shall require no library initialization. Native integral coefficient relocation shall preserve each integer representation using the implicit-lifetime wrapper property of 🔗 1. Native integral checked-number value move. |
Dense and sparse storage need consuming ownership transfer into raw slots, including overlapping right shifts, without numerical conversion or extra allocations. |
|
|
|
|
|
Exercise single transfers, empty/disjoint ranges, every overlap pattern, touching ranges, zero shift, consumed-slot reconstruction and resource-owning values. Destroy only live outputs and use sanitizers for resource misuse. Inspect lifetime creation and integer-subobject representation preservation; test matching checked/native bounded configurations as well as GMP configurations. |
src/Coefficient_relocation.hh; src/Coefficient_defs.hh; tests/coefficientrelocationspec1.cc. |
|
|
Names belong to Parma_Polyhedra_Library unless qualified otherwise. Template excerpts omit SFINAE return-type restrictions described in the text. void relocate_coefficient(Coefficient*, Coefficient*) noexcept; void relocate_coefficients(Coefficient*, Coefficient*, std::size_t) noexcept; void relocate_coefficients_right(Coefficient*, std::size_t, std::size_t) noexcept; |
||
|
SW_SPEC
|
3 |
|
|
|
Both WRD_Extended_Number_Policy and Debug_WRD_Extended_Number_Policy shall enable overflow checks, NaN and infinity representations, and requested FPU inexact checks. The production policy shall disable checks for opposite-infinity addition, same-infinity subtraction, infinity-times-zero, division by zero, infinity division, infinite remainder, negative square root and extra FPU NaN-result detection. The debugging policy shall enable all those checks. Neither policy shall define convertible or any of the five ROUND_DEFAULT_* members. Operations needing them shall require an explicitly suitable policy instead of silently selecting a default. handle_result(r) shall forward exactly results whose class is VC_NAN to throw_result_exception(r) and propagate the resulting exception. Every normal or infinity result shall be accepted without an exception, including normal-class results carrying overflow or unrepresentable flags. The policies shall require no library initialization or rounding-mode change. Arithmetic using these policies shall retain its own numerical prerequisites; disabled checks shall not authorize undefined mathematical operations. |
Weakly relational algorithms explicitly control rounding and use infinity bounds; policy capabilities and debugging diagnostics must not be mistaken for implicit defaults. |
|
|
|
|
|
Check every policy constant, absence of conversion/default-rounding members and every defined result category, including overflow/unrepresentable flags. Compare forwarded NaN exception types with throw_result_exception and require acceptance of normal/infinity categories. |
src/WRD_coefficient_types_defs.hh; src/WRD_coefficient_types_inlines.hh; tests/scalaradaptersspec1.cc. |
|
|
Names belong to Parma_Polyhedra_Library unless qualified otherwise. Template excerpts omit SFINAE return-type restrictions described in the text. struct WRD_Extended_Number_Policy; struct Debug_WRD_Extended_Number_Policy; // Member of each policy: static void handle_result(Result); |
||
|
SW_SPEC
|
4 |
|
|
|
For a live initialized interval, f_is_empty, f_is_singleton and infinity_sign shall return the corresponding member query. In Interval_NS, f_lower, f_upper and f_info shall return const references to the interval's owned boundaries and metadata, preserving reference identity and the access conditions of 🔗 2. Interval endpoint and metadata references. For an admitted singleton scalar x, the two boundary adapters shall return const references to x itself. Its metadata adapter shall return a shared immutable null-information object admitting empty values and infinity, with inexact checking disabled. The overload with bool open shall return independent null-information metadata whose two boundaries have that openness. The scalar empty predicate shall return exactly is_not_a_number(x); its singleton predicate shall negate that result. is_singleton_integer(x) shall return true exactly when the interval or scalar is a singleton and its lower value is integral. It shall not read a lower payload after a false singleton result. check_empty_arg(x) shall return the empty predicate when the metadata admits emptiness; otherwise the caller shall supply a nonempty argument and the helper shall return false. These adapters shall preserve their arguments and add no allocation, initialization or rounding prerequisites to the selected scalar/member query. |
Generic interval algorithms need borrowed views of actual intervals and singleton scalars without copying endpoints or reading inactive empty payloads. |
|
|
|
|
|
Check reference identity, shared/independent metadata, both openness states, empty/singleton/nonsingleton intervals, integral/fractional scalars, NaN and admitted infinities. Exercise the nonempty-only metadata branch and short-circuiting over empty intervals. |
src/Interval_inlines.hh; src/Interval_defs.hh; tests/scalaradaptersspec1.cc. |
|
|
Names belong to Parma_Polyhedra_Library unless qualified otherwise. Template excerpts omit SFINAE return-type restrictions described in the text. template <typename B, typename I> bool f_is_empty(const Interval<B,I>&); template <typename B, typename I> bool f_is_singleton(const Interval<B,I>&); template <typename B, typename I> int infinity_sign(const Interval<B,I>&); namespace Interval_NS { // Overloads for intervals and admitted singleton scalars: template <typename T> const auto& f_lower(const T&); template <typename T> const auto& f_upper(const T&); template <typename T> const auto& f_info(const T&); template <typename T> Scalar_As_Interval_Info_Open f_info(const T&, bool); } template <typename T> bool is_singleton_integer(const T&); template <typename T> bool check_empty_arg(const T&); |
||
|
SW_SPEC
|
5 |
|
|
|
maybe_assign(top,tmp,from,dir) shall select its behavior from the exact source and destination C++ types. If they are identical, it shall set top to the address of from, leave tmp unchanged and return V_EQ; it shall perform no numerical conversion or allocation. Otherwise it shall set top to the address of tmp, perform assign_r(tmp,from,dir) and return that operation's result. Its dispatch structs shall have the same behavior. The operands shall remain live; temporary storage shall be initialized as required by the selected assignment. For differing types, the assignment's admitted values, rounding direction, aliasing, initialization, resource and exception conditions shall apply. If assignment throws, top shall already designate tmp and the assignment's destination guarantee shall apply. Borrowing shall not extend the source lifetime. A returned pointer shall not be used after its referent is destroyed or invalidated. |
Distance kernels can avoid a conversion and scratch write when the input already has the required exact type, while exposing conversion outcomes otherwise. |
|
|
|
|
|
Check address identity, untouched same-type scratch, value/result equivalence to explicit assignment for exact and directed inexact conversions, and selected assignment exceptions with top already changed. Exercise both the public helper and dispatch specializations. |
src/distances_inlines.hh; tests/scalaradaptersspec1.cc. |
|
|
Names belong to Parma_Polyhedra_Library unless qualified otherwise. Template excerpts omit SFINAE return-type restrictions described in the text. template <typename To, typename From> Result maybe_assign(const To*&, To&, const From&, Rounding_Dir); template <typename To, typename From> struct maybe_assign_struct; // Static member of each general/same-type dispatch struct: static Result function(const To*&, To&, const From&, Rounding_Dir); |
||
|
SW_SPEC
|
6 |
|
|
|
check_space_dimension_overflow(dim,max,domain,method,reason) shall return dim unchanged when dim ≤ max. Otherwise it shall throw std::length_error with a message formed from domain, method, ":", a newline, reason and "." in that order. The string arguments shall point to live null-terminated character sequences. The accepted path shall allocate no storage; message construction failures shall propagate. It shall require no library initialization. The free max_space_dimension() shall return the minimum of the limits for Variable, both polyhedron topologies, Grid, Rational_Box, Box<Integer_Interval> and the BD/octagonal shapes instantiated with each of int8_t, int16_t, int32_t, int64_t, float, double, long double, mpz_class and mpq_class. Repeated calls shall return the same limit. A custom box interval type shall retain its own limit; the common value shall not promise successful allocation or a limit for every user-defined domain. First-use cache access shall follow the configured thread-local/global storage model and be synchronized accordingly. |
Dimension rejection must precede impossible storage requests, and the common domain limit must account for every listed built-in representation. |
|
|
|
|
|
Check zero, equality, immediately excessive and greatest representable dimensions with exact diagnostic text, then independently take the minimum of all listed static domain limits and repeat the free query. Check callability before PPL initialization separately from shared-cache synchronization. |
src/globals.cc; src/globals_defs.hh; src/max_space_dimension.hh; tests/scalaradaptersspec1.cc; tests/scalaradapterspreinit1.cc. |
|
|
Names belong to Parma_Polyhedra_Library unless qualified otherwise. Template excerpts omit SFINAE return-type restrictions described in the text. dimension_type check_space_dimension_overflow(dimension_type, dimension_type, const char*, const char*, const char*); dimension_type max_space_dimension(); |