I don't know if it's an undefined behavior or a bug. The environment is fpc 2.6-bugfix branch x86-64 linux. See the details in the attached code
program t2; {$mode objfpc} uses sysUtils; type ip= interface ['{f0cea771-a3f1-4223-bea2-c46c5f0f61fa}'] end; iq= interface ['{11d7c834-7fcf-4837-bccc-fa92418a049b}'] end;
cl= class(tInterfacedObject, ip, iq) public destructor destroy; override; end; destructor cl.destroy; begin writeln('cl destroyed'); end; type cm= class(tInterfacedObject, ip, iq) public fi: cl; property i0: cl read fi implements ip; property i1: cl read fi implements iq; constructor create; virtual; destructor destroy; override; end; constructor cm.create; begin fi:= cl.create; end; destructor cm.destroy; begin freeAndNil(fi); end; var v: cm; i: ip; begin v:= cm.create; writeln(ptruint(v)); writeln(ptruint(v as ip)); // it prints 'cl destroyed' // i:= v; // if uncommented this line, no exception would be raised. But in delphi, the next statement works well even leave it commented. writeln(ptruint(v as iq)); // EAccessViolation : Access violation end.
_______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal