Initialization of opaque fields with unknown size #1084
Labels
architectural decision
Discussion of design decision
specification
Related to specification package (e.g., specification parsing)
Context and Problem Statement
Currently the only way to initialize opaque fields in the spec is to either use a static aggregate or a function. While the static aggregate works well when the size is known sometimes it's required to zero-initialize an opaque field whose size is not known statically. In this case the only way to initialize this field is by using a function.
Use Cases
Zero-initialization of fields with a dynamic size that are modified later (e.g. a signature or hash).
Considered Options
O1
Using others to match whatever size the opaque field has with a static value.
+ Close to Ada syntax
+ Allows custom values for all bytes
− Only allows a single value for all bytes
O2
Using a range assignment:
+ Close to Ada syntax
+ More flexible in terms of different initial values for different ranges
− Always requires the length to be known via a variable
− Additional non-overlap checks necessary
O3
Using an reset aspect:
Opaque_Field'Reset (Opaque_Field_Length, 0);
+ Consistent to other
Reset
aspects such as for messages and sequences− Less flexible as it only allows a single value to be set
− Always requires the length to be known via a variable
Decision Outcome
O1
The text was updated successfully, but these errors were encountered: