[Lazarus] SEGFAULT: difference between pointer and dynarray?

xrfang xrfang at gmail.com
Sat Dec 29 07:20:17 CET 2012


Hi leledumbo,

You are right that they are not same:

begin
  setlength(a1,1);
  a1[0] := 12345;
  getvalue(@a1);
  getvalue(@a1[0]);
end.  

The assembly code for the 2 getvalue() are:

project1.lpr:14 getvalue(@a1);
000000000040022F 48bf40a2620000000000 movabs $0x62a240,%rdi
0000000000400239 e862ffffff           callq 0x4001a0 <GETVALUE>
project1.lpr:15 getvalue(@a1[0]);
000000000040023E 488b3c2540a26200     mov 0x62a240,%rdi
0000000000400246 e855ffffff           callq 0x4001a0 <GETVALUE>

One used movabs, and the other use mov.  But why the generated assembly in my code are same?

Shannon


在 六, 12月 29, 2012 at 1:26 下午,leledumbo <leledumbo_cool at yahoo.co.id> 写道:
> The Assembler shows that @lib and @lib[0] are exactly same thing. 

The following program shows that they are NOT the same 

#!/usr/bin/instantfpc 
var 
a1: array of Integer; 
begin 
setlength(a1,1); 
writeln(ptruint(@a1)); 
writeln(ptruint(@a1[0])); 
end. 

output: 
$ chmod +x test.pas 
$ ./test.pas 
134651632 
3077795880 



-- 
View this message in context: http://free-pascal-lazarus.989080.n3.nabble.com/Lazarus-SEGFAULT-difference-between-pointer-and-dynarray-tp4028296p4028303.html 
Sent from the Free Pascal - Lazarus mailing list archive at Nabble.com. 

-- 
_______________________________________________ 
Lazarus mailing list 
Lazarus at lists.lazarus.freepascal.org 
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20121229/3238e90f/attachment-0003.html>


More information about the Lazarus mailing list