BS is a dynamic array. sizeOf (https://wiki.freepascal.org/Dynamic_array#handling) a dynamic array variable returns the size of a pointer, not the dynamically allocated array data. You actually wanted to write
fillchar(BS[0],sizeof(BS),1);
but then I am wondering why you aren’t simply using a for loop and a plain := assignment.
btw.: Are elements of a dynamic array initialized with zeros or not?AFAIK all such compiler-managed types are initialised with zeros.
Hard to find an answer in the docs.
btw.: Are elements of a dynamic array initialized with zeros or not?AFAIK all such compiler-managed types are initialised with zeros.
Hard to find an answer in the docs.
A few notes:...
...
- bitpacked (what you probably wanted) is not allowed for dynamic arrays
In essence the data of your TBigSet will always be a multiple of a Byte. For really accessing bits in the array you need to do this manually using bit operators.
So you have to fool the compiler:
I wouldn't say that this is fooling the compiler as you're simply using language features the way they're supposed to be used... :-X