diff --git a/compiler/optvirt.pas b/compiler/optvirt.pas index 198ff4e646..9b10580aec 100644 --- a/compiler/optvirt.pas +++ b/compiler/optvirt.pas @@ -706,7 +706,10 @@ unit optvirt; defunitclassname(node.def,unitid,classid,classprefix); unitdevirtinfo:=addunitifnew(unitid^); classdevirtinfo:=unitdevirtinfo.addclass(classprefix+classid^,node.instantiated); - if (node.def.vmtentries.count=0) then + { node.def.vmcallstaticinfo can be nil if the object only has abstract + virtual methods } + if (node.def.vmtentries.count=0) or + not assigned(node.def.vmcallstaticinfo) then exit; for i:=0 to node.def.vmtentries.count-1 do if (po_virtualmethod in pvmtentry(node.def.vmtentries[i])^.procdef.procoptions) then diff --git a/tests/webtbs/tw41077.pp b/tests/webtbs/tw41077.pp new file mode 100644 index 0000000000..cef1a7b0ca --- /dev/null +++ b/tests/webtbs/tw41077.pp @@ -0,0 +1,21 @@ +{ %wpoparas=optvmts } +{ %wpopasses=1 } + + +program test; + +type + PMyObj=^TMyObj; + TMyObj = object + constructor init; + procedure dummy;virtual;abstract; + end; + +constructor TMyObj.init; +begin +end; + +begin + PMyObj(nil)^.init; +end. +