On 15 Mar 2001, at 2:07, Frank Heckenbach wrote:
David James wrote:
That is the PACKED ARRAY of 0..255 occupied 4 bytes under the old version and now occupies 16 bytes. Whilst I clearlyu have a workaround by switching from 0..255 to byte, that behaviour doesn't seem right to me.
Indeed, this seems like a bug to me (daj14.pas).
Regarding the PACKED keyword, the EP standard has only this to say (section 6.4.3.1):
"The designation of a structured-type as packed shall indicate to the processor that data-storage of states should be economized, even if this causes operations on, or accesses to components of, variables possessing the type to be less efficient in terms of space or time."
The word "should" above indicates, I believe, that GPC may either reduce the storage size or not reduce the storage size, i.e., PACKED may do something, or it may not; it's up to the compiler. Of course, it would be helpful if GPC did reduce the size, either to the minimum number of bits required, or to some multiple of the minimum addressable storage element (e.g., a byte for most machines).
...(and the real bug seems to be that GPC doesn't carry over the `packed' to the array component).
a3:packed array[1..maxnum] of packed 0..255;
I'm not sure whether you intend for "packed" to be carried over to _all_ array components, but note that the same section of the EP standard says:
"The designation of the structured-type as packed shall affect the representation in data-storage of that structured type only; i.e., if a component is itself structured, the component's representation in data-storage shall be packed only if the type of the component itself is designated packed."
This appears to state that:
a : packed array [1..5] of array [1..5] of 0..255;
...is _not_ equivalent to:
a : packed array [1..5] of packed array [1..5] of 0..255;
-- Dave