mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-22 07:09:29 +02:00
* fixed loading the vmt of TP-style objects when it's not at offset zero
(for virtual procvars of object, mantis #17521) git-svn-id: trunk@16190 -
This commit is contained in:
parent
843ce22187
commit
dd8fd7cd4a
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -10700,6 +10700,7 @@ tests/webtbs/tw1744.pp svneol=native#text/plain
|
||||
tests/webtbs/tw17458.pp svneol=native#text/plain
|
||||
tests/webtbs/tw17493.pp svneol=native#text/plain
|
||||
tests/webtbs/tw17514.pp svneol=native#text/plain
|
||||
tests/webtbs/tw17521.pp svneol=native#text/plain
|
||||
tests/webtbs/tw17546.pp svneol=native#text/plain
|
||||
tests/webtbs/tw1754c.pp svneol=native#text/plain
|
||||
tests/webtbs/tw1755.pp svneol=native#text/plain
|
||||
|
@ -512,7 +512,7 @@ implementation
|
||||
if (left.resultdef.typ<>classrefdef) then
|
||||
begin
|
||||
{ load vmt pointer }
|
||||
reference_reset_base(href,hregister,0,sizeof(pint));
|
||||
reference_reset_base(href,hregister,tobjectdef(left.resultdef).vmt_offset,sizeof(pint));
|
||||
hregister:=cg.getaddressregister(current_asmdata.CurrAsmList);
|
||||
cg.a_load_ref_reg(current_asmdata.CurrAsmList,OS_ADDR,OS_ADDR,href,hregister);
|
||||
end;
|
||||
|
33
tests/webtbs/tw17521.pp
Normal file
33
tests/webtbs/tw17521.pp
Normal file
@ -0,0 +1,33 @@
|
||||
{$mode objfpc}
|
||||
{$h+}
|
||||
|
||||
|
||||
type tx = object
|
||||
a,b,c: longint; // remove these => no crash
|
||||
constructor init;
|
||||
function v: longint; virtual;
|
||||
end;
|
||||
px = ^tx;
|
||||
|
||||
constructor tx.init;
|
||||
begin
|
||||
end;
|
||||
|
||||
function tx.v: longint;
|
||||
begin
|
||||
v:=b;
|
||||
end;
|
||||
|
||||
var t : function:longint of object;
|
||||
p : px;
|
||||
|
||||
begin
|
||||
new( p, init );
|
||||
p^.a:=3;
|
||||
p^.b:=4;
|
||||
p^.c:=5;
|
||||
p^.v; // ok
|
||||
t := @p^.v; // sigsegv
|
||||
if t()<>4 then
|
||||
halt(1);
|
||||
end.
|
Loading…
Reference in New Issue
Block a user