This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: `size_volatile' types
Jeffrey A. Law wrote:
> I didn't understand the "or even for one and the same object within its scope".
>
> Are you trying to say that the size/offsets can vary for two objects of the
> same type within the same scope? Or are you trying to say that the
> positions/types of the sam object can vary within the scope of the object?
Yes, the size of one variable (the target of a pointer) can
change within the scope of the variable. To illustrate this,
here is a short example:
Program Foo;
Type
A ( n: Integer ) = array [ 1..n ] of Integer;
Var
A42: A ( 42 ); (* an `array [ 1..42 ] of Integer' variable *)
A137: A ( 137 ); (* an `array [ 1..137 ] of Integer' variable *)
B: ^A; (* a pointer do an `A' with arbitrary `n' *)
begin
B:= @A42; (* Assign the address of `A42' to `B' *)
writeln ( SizeOf ( B^ ) ); (* Yields 172 on my machine *)
B:= @A137;
writeln ( SizeOf ( B^ ) ) (* Yields 552 on my machine *)
end.
Since TYPE_SIZE (TREE_TYPE (B^)) (i.e. the size of the object
pointed to by `B') varies within the scope of `B', we must not
construct a SAVE_EXPR for this size. Instead, the expression
for TYPE_SIZE (TREE_TYPE (B^)) contains `B^' as a PLACEHOLDER_EXPR.
Peter