Incorrect RTTI generated for big sets
Original Reporter info from Mantis: Gorelkin
-
Reporter name: Sergei Gorelkin
Original Reporter info from Mantis: Gorelkin
- Reporter name: Sergei Gorelkin
Description:
RTTI generated for 'big' sets differs from one generated for small sets. The difference is in the byte immediately following TTypeInfo.Name: it is absent for big sets. I assume that it must be present, because otherwise GetTypeData would be broken for all other types (and that wouldn't go unnoticed).
Btw, nothing in typinfo.pp mentions that this byte should be present. The comment at line 74 is misleading, saying that TTypeInfo is followed by TTypeData, while actually TTypeInfo is followed by that byte and the address of TTypeData.
The following program illustrates the issue. Uncommenting the commented out line makes it work as expected.
program t;
{$mode objfpc}{$h+}
uses typinfo;
type
tsmall = 0..11;
tsmallset = set of tsmall;
tbig = 25..33;
tbigset_ = set of tbig;
var
ti: PTypeInfo;
tdata: PTypeData;
begin
ti := typeinfo(tsmallset);
tdata := GetTypeData(ti);
if tdata^.CompType = typeinfo(tsmall) then
writeln('small ok')
else
halt(1);
ti := typeinfo(tbigset_);
tdata := GetTypeData(ti);
//dec(pchar(tdata));
if tdata^.CompType = typeinfo(tbig) then
writeln('big ok')
else
halt(2);
end.
Mantis conversion info:
- Mantis ID: 12788
- Version: 2.3.1
- Fixed in version: 2.4.0
- Fixed in revision: 12371 (#e213be26)