mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-22 11:49:23 +02:00

with the enum instance corresponding to ordinal 0 in JVM constructors, because a virtual method called by a parent constructor may already have assigned a different value (see tests/test/jvm/tenum2.pp). This will result in null pointer exceptions when using such fields without first explicitly assigning a value to them though. The old behaviour can be restored with the new -CTenumfieldinit command line parameter git-svn-id: trunk@21736 -
35 lines
489 B
ObjectPascal
35 lines
489 B
ObjectPascal
program tenum2;
|
|
|
|
{$mode delphi}
|
|
|
|
type
|
|
tenum2enum = (e_zero, e_one, e_two);
|
|
|
|
tenum2base = class abstract
|
|
constructor create;
|
|
procedure init; virtual; abstract;
|
|
end;
|
|
|
|
tenum2child = class(tenum2base)
|
|
fenum: tenum2enum;
|
|
procedure init; override;
|
|
end;
|
|
|
|
constructor tenum2base.create;
|
|
begin
|
|
init;
|
|
end;
|
|
|
|
procedure tenum2child.init;
|
|
begin
|
|
fenum:=e_one;
|
|
end;
|
|
|
|
var
|
|
c: tenum2child;
|
|
begin
|
|
c:=tenum2child.create;
|
|
if c.fenum<>e_one then
|
|
halt(1);
|
|
end.
|