f.couperin wrote:
Hello,
Here is a surprising bug I discovered. It's about variables of the set type in procedures.
-- Program SetBug2;
Procedure Try; Var X : Integer = 1; OneSet : Set Of Integer = [1]; Begin If X In OneSet Then Writeln('OK') End; Begin Try End.
Since GPC stores sets as bitfields, a full set of Integer would take 512 MB on a 32 bit system (and much more on a 64 bit system). Of course, the compiler should not crash (couper11.pas).
To solve the problem, declare the set of a more appropriate subrange type. This will also be necessary when this particular bug will be fixed. Maybe in the future, GPC will support a more compact representation for "sparse" sets, so the above will actually work, but that's not a top priority...
Frank