Parma Polyhedra Library requirements
Internal dirty-temporary caches and holders

Internal dirty-temporary caches and holders

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-000891
PPL-SPEC-000891
Temporary-cache values, leases and element prerequisites

The internal temporary mechanism shall manage live objects of the selected type T, either through a pool-backed lease or a local value holder. Each selected operation shall require the element construction, destruction and resource capabilities it actually invokes; copying or moving T shall not be required merely to obtain, use or return a pooled item. Element destruction shall not throw. Clients shall retain T's own numerical/runtime prerequisites. No additional global PPL initialization shall be required for unrelated element types.

An active pool lease shall give its caller exclusive use of that item's element value until release. A released item shall belong to the cache, and the caller shall not keep accessing it through an old reference. Pool operations that affect a common free list shall not overlap without caller synchronization. Context/teardown conditions shall retain 🔗 12. Cache contexts, teardown and retained storage lifetime.

Temporary reuse needs ownership and value-lifetime rules independently of any coefficient type.

APPROVED
RUNTIME
IF_CPP
Test, Analysis, Inspection

Instantiate noncopyable, resource-owning and over-aligned element types without PPL initialization; check unique active leases, borrowed references and supported context histories.

src/Temp_defs.hh; src/Temp_inlines.hh; src/Temp_templates.hh; src/Slow_Copy.hh; src/thread_safe.hh; src/Init.cc; tests/tempcachespec1.cc; tests/tempcacheallocation.hh.

CPP
Internal

Internal source headers: Temp_defs.hh, Temp_inlines.hh, Temp_templates.hh and Slow_Copy.hh. Names belong to Parma_Polyhedra_Library except the declaration macro. Member excerpts apply to their corresponding class template.

template <typename T> class Temp_Item;
template <typename T> class Temp_Reference_Holder;
template <typename T> class Temp_Value_Holder;
SW_SPEC
2
PPL-SPEC-000892
PPL-SPEC-000892
Slow-copy trait selection and built-in GMP classifications

Slow_Copy<T> shall classify ordinary types as false unless a supported specialization selects otherwise. Its GMP integer and rational specializations shall classify mpz_class and mpq_class as true. The classification shall select storage strategy under 🔗 9. Dirty temporary storage strategy; it shall not itself construct, copy, move or initialize an element object. A selected user specialization shall be visible before the corresponding temporary-holder instantiation.

The storage choice depends on an explicit type trait rather than a runtime guess or extra element copy.

APPROVED
RUNTIME
IF_CPP
Test, Analysis, Inspection

Check default/GMP/user-specialized trait values and resulting holder bases with type traits, including noncopyable test elements.

src/Temp_defs.hh; src/Temp_inlines.hh; src/Temp_templates.hh; src/Slow_Copy.hh; src/thread_safe.hh; src/Init.cc; tests/tempcachespec1.cc; tests/tempcacheallocation.hh.

CPP
Internal

Internal source headers: Temp_defs.hh, Temp_inlines.hh, Temp_templates.hh and Slow_Copy.hh. Names belong to Parma_Polyhedra_Library except the declaration macro. Member excerpts apply to their corresponding class template.

template <typename T> struct Slow_Copy;
template <> struct Slow_Copy<mpz_class>;
template <> struct Slow_Copy<mpq_class>;
SW_SPEC
3
PPL-SPEC-000893
PPL-SPEC-000893
Obtaining a fresh or retained pool item

Temp_Item<T>::obtain() shall return a reference to a live item exclusively leased from the calling context's pool. If no cached item is available, it shall allocate a new item and value-initialize its T object. Otherwise it shall remove one cached item from the free pool without reconstructing, copying or resetting its T value. Different simultaneously active leases shall refer to different items. No ordering among several available cached items shall be required. Allocation or element-construction failure shall retain 🔗 11. Allocation and element-construction failure cleanup.

A dirty temporary may retain a prior value, while a newly allocated item has a distinct construction path.

APPROVED
RUNTIME
IF_CPP
Test, Analysis, Inspection

Compare active item identity sets and exact tracked construction counts; exercise empty/nonempty pools, native value initialization, retained values and failed fresh allocation/construction.

src/Temp_defs.hh; src/Temp_inlines.hh; src/Temp_templates.hh; src/Slow_Copy.hh; src/thread_safe.hh; src/Init.cc; tests/tempcachespec1.cc; tests/tempcacheallocation.hh.

CPP
Internal

Internal source headers: Temp_defs.hh, Temp_inlines.hh, Temp_templates.hh and Slow_Copy.hh. Names belong to Parma_Polyhedra_Library except the declaration macro. Member excerpts apply to their corresponding class template.

static Temp_Item& obtain();
SW_SPEC
4
PPL-SPEC-000894
PPL-SPEC-000894
Returning a lease without destroying its value

Temp_Item<T>::release(item) shall return one currently active lease to the calling context's free pool without destroying or resetting its T object or allocating another item. Its value shall remain owned by the cache for later reuse or cleanup. The caller shall release each lease exactly once, shall not release an already cached/dead item, and shall cease access through its old lease. A serialized cross-context handoff shall be admitted when T permits it and the item is returned to a live destination context under 🔗 12. Cache contexts, teardown and retained storage lifetime; returning an item shall not depend on an inaccessible origin-thread identifier.

Returning storage transfers it to the current cache without ending the element lifetime or requiring a new allocation.

APPROVED
RUNTIME
IF_CPP
Test, Analysis, Inspection

Disable allocation during returns/reuse, check retained values and construction/destruction counts, exercise several return orders and a type-permitted serialized lease handoff.

src/Temp_defs.hh; src/Temp_inlines.hh; src/Temp_templates.hh; src/Slow_Copy.hh; src/thread_safe.hh; src/Init.cc; tests/tempcachespec1.cc; tests/tempcacheallocation.hh.

CPP
Internal

Internal source headers: Temp_defs.hh, Temp_inlines.hh, Temp_templates.hh and Slow_Copy.hh. Names belong to Parma_Polyhedra_Library except the declaration macro. Member excerpts apply to their corresponding class template.

static void release(Temp_Item& item);
SW_SPEC
5
PPL-SPEC-000895
Qualified item reference and admitted borrowing

Temp_Item<T>::item() shall return a reference with the declared T& qualification to the same owned object on each call during that item's active lease. For a modifiable T, writes through this reference shall be visible through the lease and to later admitted reuse of that object. The accessor shall not allocate, copy, reconstruct or release the item. The returned reference shall not authorize access after release, holder destruction or actual object cleanup.

Clients use the temporary value through a borrowed reference, whose lifetime is shorter than retained cache storage.

APPROVED
RUNTIME
IF_CPP
Test, Analysis, Inspection

Check exact reference identity, independent active values, serial updates and retained reuse with allocation disabled.

src/Temp_defs.hh; src/Temp_inlines.hh; src/Temp_templates.hh; src/Slow_Copy.hh; src/thread_safe.hh; src/Init.cc; tests/tempcachespec1.cc; tests/tempcacheallocation.hh.

CPP
Internal

Internal source headers: Temp_defs.hh, Temp_inlines.hh, Temp_templates.hh and Slow_Copy.hh. Names belong to Parma_Polyhedra_Library except the declaration macro. Member excerpts apply to their corresponding class template.

T& item() &;
SW_SPEC
6
PPL-SPEC-000896
PPL-SPEC-000896
Pool-item construction and ownership restrictions

Clients shall acquire Temp_Item<T> objects through obtain and return them through release. Ordinary client default construction, copy construction and assignment shall be inaccessible; no supported move operation shall transfer a leased item implicitly. The cache shall own item destruction, and a leased item shall not be deleted directly by its caller. Stable live item identity shall be retained through admitted use and return until actual cache cleanup.

An item is a pool-owned object with an explicit lease protocol rather than a copyable value wrapper.

APPROVED
RUNTIME
IF_CPP
Test, Analysis, Inspection

Check inaccessible construction/copy/move/assignment and exact active/reused identities without invoking forbidden direct destruction.

src/Temp_defs.hh; src/Temp_inlines.hh; src/Temp_templates.hh; src/Slow_Copy.hh; src/thread_safe.hh; src/Init.cc; tests/tempcachespec1.cc; tests/tempcacheallocation.hh.

CPP
Internal

Internal source headers: Temp_defs.hh, Temp_inlines.hh, Temp_templates.hh and Slow_Copy.hh. Names belong to Parma_Polyhedra_Library except the declaration macro. Member excerpts apply to their corresponding class template.

template <typename T> class Temp_Item;
SW_SPEC
7
PPL-SPEC-000897
PPL-SPEC-000897
Reference-holder acquisition, access and scope cleanup

A Temp_Reference_Holder<T> shall acquire exactly one pool item on successful construction and return it on destruction, including ordinary exception unwinding. Its item() shall return the leased object under 🔗 5. Qualified item reference and admitted borrowing. Holder destruction shall not destroy the retained T or allocate another item. Each separate default construction shall acquire its own lease. Copy construction, assignment and moving shall be inaccessible. A returned value reference shall remain borrowed only while that holder is live and retains its lease. Calling item() on a temporary reference holder shall be ill-formed.

A scope-bound holder makes pool return automatic without changing the temporary element's value lifetime.

APPROVED
RUNTIME
IF_CPP
Test, Analysis, Inspection

Check nested holders, unique active references, reuse after normal exit and throwing scopes, inaccessible copy/move and allocation-free destructor behavior.

src/Temp_defs.hh; src/Temp_inlines.hh; src/Temp_templates.hh; src/Slow_Copy.hh; src/thread_safe.hh; src/Init.cc; tests/tempcachespec1.cc; tests/tempcacheallocation.hh.

CPP
Internal

Internal source headers: Temp_defs.hh, Temp_inlines.hh, Temp_templates.hh and Slow_Copy.hh. Names belong to Parma_Polyhedra_Library except the declaration macro. Member excerpts apply to their corresponding class template.

Temp_Reference_Holder();
~Temp_Reference_Holder();
T& item() &;
SW_SPEC
8
PPL-SPEC-000898
PPL-SPEC-000898
Local value-holder construction and lifetime

Temp_Value_Holder<T> shall own one local T object, default initialized as a normal member. A class type's default constructor shall run; a fundamental type shall not gain an initial-value guarantee from this holder. Its item() shall return a reference with the declared T& qualification to that same local object. Destruction shall destroy that owned object rather than cache it. The holder itself shall perform no separate pool allocation, copy or move, while retaining resources and construction failures intrinsic to T. Copy construction, assignment and moving shall be inaccessible.

Fast-copy temporaries use ordinary local lifetime and must not inherit the pool's retained-value behavior or an invented zero-initialization guarantee.

APPROVED
RUNTIME
IF_CPP
Test, Analysis, Inspection

Check class construction/destruction and value independence, native types assigned before reads, exact reference identity, no-copy/move traits and element-construction failure cleanup.

src/Temp_defs.hh; src/Temp_inlines.hh; src/Temp_templates.hh; src/Slow_Copy.hh; src/thread_safe.hh; src/Init.cc; tests/tempcachespec1.cc; tests/tempcacheallocation.hh.

CPP
Internal

Internal source headers: Temp_defs.hh, Temp_inlines.hh, Temp_templates.hh and Slow_Copy.hh. Names belong to Parma_Polyhedra_Library except the declaration macro. Member excerpts apply to their corresponding class template.

Temp_Value_Holder();
T& item() &;
SW_SPEC
9
PPL-SPEC-000899

For a selected T, Dirty_Temp<T> shall use the Temp_Reference_Holder<T> interface when Slow_Copy<T>::value is true and Temp_Value_Holder<T> when false. It shall retain the chosen holder's ownership, initialization, borrowing and failure rules without adding an element copy, move or numeric initialization stage. The result shall be a dirty temporary; clients shall establish the value required by their computation rather than assume a fresh numerical zero.

The same internal expression should select an appropriate lifetime strategy without changing value prerequisites.

APPROVED
RUNTIME
IF_CPP
Test, Analysis, Inspection

Check both inheritance selections, tracked slow/fast types and native values assigned before use; compare construction/destruction/reuse counts and exception histories.

src/Temp_defs.hh; src/Temp_inlines.hh; src/Temp_templates.hh; src/Slow_Copy.hh; src/thread_safe.hh; src/Init.cc; tests/tempcachespec1.cc; tests/tempcacheallocation.hh.

CPP
Internal

Internal source headers: Temp_defs.hh, Temp_inlines.hh, Temp_templates.hh and Slow_Copy.hh. Names belong to Parma_Polyhedra_Library except the declaration macro. Member excerpts apply to their corresponding class template.

template <typename T, typename Enable = void> class Dirty_Temp;
SW_SPEC
10
PPL-SPEC-000900
PPL-SPEC-000900
Dirty-temporary declaration macro and lexical lifetime

PPL_DIRTY_TEMP(T, id) shall declare a corresponding local Dirty_Temp<T> holder and a T& named id bound to its item(). The type shall be supplied as one preprocessor argument; a type with commas shall use a suitable alias. The caller shall provide a usable fresh identifier and declaration scope, including the generated holder name, and terminate the invocation as a declaration. The macro shall preserve the selected holder lifetime through that lexical scope, including unwinding; id shall not authorize an escaping reference beyond it. The macro shall not copy or implicitly initialize the value beyond 🔗 9. Dirty temporary storage strategy.

A declaration macro must preserve actual type/reference and scope semantics, including comma-bearing template types passed through aliases.

APPROVED
RUNTIME
IF_CPP
Test, Analysis, Inspection

Compile distinct/nested identifiers and aliased template types; check exact reference types, both storage strategies and cleanup through throwing lexical scopes.

src/Temp_defs.hh; src/Temp_inlines.hh; src/Temp_templates.hh; src/Slow_Copy.hh; src/thread_safe.hh; src/Init.cc; tests/tempcachespec1.cc; tests/tempcacheallocation.hh.

CPP
Internal

Internal source headers: Temp_defs.hh, Temp_inlines.hh, Temp_templates.hh and Slow_Copy.hh. Names belong to Parma_Polyhedra_Library except the declaration macro. Member excerpts apply to their corresponding class template.

PPL_DIRTY_TEMP(Type, identifier);
using Type_Alias = Template_Type<Argument1, Argument2>;
PPL_DIRTY_TEMP(Type_Alias, identifier);
SW_SPEC
11
PPL-SPEC-000901
PPL-SPEC-000901
Allocation and element-construction failure cleanup

If a fresh pool item cannot be allocated, or its T construction throws, the exception shall propagate without leaking the incomplete item's storage or adding an incomplete item to the free pool. Previously active items and cached values shall remain usable and unchanged. Element-owned subresources shall follow the element constructor's own C++ cleanup obligations. A failed holder construction shall not acquire an active lease. A failed local value-holder construction shall likewise retain its element's cleanup protocol. A later successful attempt shall remain possible; obtaining an already cached item shall not require a fresh element construction or item allocation.

Failure must preserve existing temporary leases and leave no unowned partial cache node.

APPROVED
RUNTIME
IF_CPP
Test, Analysis, Inspection

Inject each new-allocation boundary and a class-constructor exception after member acquisition, verify exact resource/lease preservation and retry through raw, reference-holder and local-holder forms.

src/Temp_defs.hh; src/Temp_inlines.hh; src/Temp_templates.hh; src/Slow_Copy.hh; src/thread_safe.hh; src/Init.cc; tests/tempcachespec1.cc; tests/tempcacheallocation.hh.

CPP
Internal

Internal source headers: Temp_defs.hh, Temp_inlines.hh, Temp_templates.hh and Slow_Copy.hh. Names belong to Parma_Polyhedra_Library except the declaration macro. Member excerpts apply to their corresponding class template.

static Temp_Item& obtain();
Temp_Reference_Holder();
Temp_Value_Holder();
SW_SPEC
12
PPL-SPEC-000902
Cache contexts, teardown and retained storage lifetime

Each Temp_Item<T> specialization shall maintain an independent free pool. In a thread-safe configuration it shall be thread-local; otherwise it shall be shared static storage requiring serialized conflicting operations. Cached free items shall be destroyed, with their owned values/resources, when that pool's thread or static context is destroyed. Outstanding active leases shall remain the caller's return responsibility and shall not be mistaken for cached free items. Calls shall not use a pool after its teardown has begun or completed.

An element-permitted lease handoff may outlive the originating thread and be returned to another live context after synchronization; free-pool cleanup shall not destroy that outstanding lease. Cache storage shall not be cleared merely because a separate PPL initialization owner is finalized. These rules shall not relax T's own initialization, thread-affinity or value-lifetime restrictions.

A pool owns only returned items, and its storage lifetime differs from both active leases and library initialization owners.

APPROVED
RUNTIME
IF_CPP
Test, Analysis, Inspection

Check per-type isolation, thread-local cleanup of returned items, synchronized outstanding-lease handoff, final process cleanup with an ordered exit observer, and inspection of PPL lifecycle independence.

src/Temp_defs.hh; src/Temp_inlines.hh; src/Temp_templates.hh; src/Slow_Copy.hh; src/thread_safe.hh; src/Init.cc; tests/tempcachespec1.cc; tests/tempcacheallocation.hh.

CPP
Internal

Internal source headers: Temp_defs.hh, Temp_inlines.hh, Temp_templates.hh and Slow_Copy.hh. Names belong to Parma_Polyhedra_Library except the declaration macro. Member excerpts apply to their corresponding class template.

template <typename T> class Temp_Item;