There is an issue with locally static subtypes in FT22.
Take the following example:
package p1 is
constant c1: integer; -- deferred constant;
subtype shortInt is integer c1 downto 0;
array arrayType is array ( shortInt range <> ) of bit;
constant arrayConst : arrayType := "0000";
constant arrayConst2 : arrayType := arrayConst & arrayConst;
end package;
By the current locally static expression rules arrayConst is
locally static because of items a and b in the list in section
7.4.1. What is interesting is that the bounds of arrayConst are
unknown because C1 is a deferred constant and not known.
With the modified rules of FT22 then arrayConst2 would also be
locally static but again here we don't know the bounds or arrayConst2.
Why do we care about the bounds? We know the length in both cases.
If we want do to allow for indexing and slice as FT22 allows, be need
to know the bound to do the correct element selection. There is also
the catching of error cases. For example if C1 is initialized to
-1 then arrayConst is an error. If arrayConst is truly locally static
the compiler may have removed the constant and force the compiler to
generate a runtime check seems a little extreme.
I believe the solution is very straight forward. If the restriction
that the subtype of an object be locally static, at least
for composite types, is added to item b in section 7.4.1.
The definition of locally static subtype type needs to be changed
also. Currently for array a locally static subtype is defined as
"A locally static array subtype is a constrained array subtype formed
by imposing on an unconstrained array type a locally static index
constraint." Section 7.4.1 line 606.
This has a boundary case where the index constraint on the array type
is not locally static. If the index constraint is not locally static
it is again impossible for the compiler to flag errors in locally
static expression at compile time. It is also impossible for the
implicit "&" to compute the correct result bounds. In 93 version
the result's bounds depend on the base type's index constraint.
So the proposal needs to be update to reflect the changes in item b
and the definition of a locally static array subtype. The ISAC is
also proposing some changes here, currently its a change in the language
of item b to.
b) A constant (other than a deferred constant) explicitly declared by
a constant declaration with a locally static subtype and initialized
with a locally static expression.
This is change in b is good.
The line
"A locally static array subtype is a constrained array subtype formed
by imposing on an unconstrained array type a locally static index
constraint." Section 7.4.1 line 606.
Would be changed to
"A locally static array subtype is a constrained array subtype formed
by imposing on an unconstrained array type with a locally static index
constraint. The unconstained array type must have a locally static element subtype
and locally static index subtype definitions."
-- -- mailto: johnr@model.com phone: (503)685-0864 -- http://www.model.com fax: (503)685-0921 --Received on Mon Nov 1 11:11:58 2004
This archive was generated by hypermail 2.1.8 : Mon Nov 01 2004 - 11:12:21 PST