Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-other / 2009-10

Re: Re: Illogical automatic dereferencing

1 message · 1 person ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Vinzent Höfler

Reimar Grabowski :

> If you have "p: PINTEGER" then you're assuming you're accessing to ONE > integer. No, YOU assume that.

And the compiler, too:

-- 8< -- snip --
{$T+} // Typed pointers, or we can assign anything.
type
  IntArray  = array[0 .. 9] of Integer;
  pInteger  = ^Integer;
  pIntArray = ^IntArray;
var
  I  : Integer;
  A  : IntArray;
var
  PI : pInteger;
  PA : pIntArray;
begin
  PI := @I;
  PA := @A;
  //PI := @A; // Does not work, wrong type.
  WriteLn (SizeOf (PI^));
  WriteLn (SizeOf (PA^));
end.
-- 8< -- snip --

Output:

2
20

Vinzent.

GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT! Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01

Reply by email