On 30/03/2014 14:35, Jonas Maebe wrote:
On 30/03/14 15:24, Martin Frb wrote:
The below program compiles fine (and generates no warning (fpc 2.6.2 /
win 32)

It only compiles fine with the (default) {$t-}. If you add {$t+}, it doesn't compile. Without typed pointers, the result of the @-operator is an untyped pointer, which by definition is assignment-compatible with all other pointer types.

Making {$t+} the default is hard because it could break existing, correct code (e.g., "untypedptr:=@wordvar+1" would result in a pointer 2 bytes after @wordvar instead of 1 with {$t+}).

Ah yes, so easy to forget... (Now I remember)


Slight change, and  I get
Fatal: Compilation aborted


program project1;
{$t+}
type
  TA = array of integer;
  PA = ^TA;
var
  a : array of integer;
  a1: PA;

procedure Foo(var c: array of integer; var c1: PA);
begin
  //c1:= @c;

  writeln( (@c)^[1] );

  //writeln(PInteger(c1)^);
  //writeln(c1^[1]);
  readln;
end;

begin
  SetLength(a,5);
  a[0]:= 100;
  a[1]:= 101;
  a1:=@a;
  foo(a,a1);
end.

_______________________________________________
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel

Reply via email to