[fpc-pascal] Access Violation When SetLength(DynArray, Value)

2022-09-08 Thread Anthony Walter via fpc-pascal
Is there a known edge case issue connected to setting the length of dynamic arrays? I have a program that simulates a billiards game, and during the rerack balls method of TPoolTable the number of pool balls on the table varies based on the rerack option used. Currently, I am having a problem wher

Re: [fpc-pascal] Access Violation When SetLength(DynArray, Value)

2022-09-08 Thread Jonas Maebe via fpc-pascal
On 2022-09-08 09:30, Anthony Walter via fpc-pascal wrote: Is there a known edge case issue connected to setting the length of dynamic arrays? No, and the location where you're getting the crash suggests an issue in your program that has corrupted the heap manager state. Jonas _

Re: [fpc-pascal] Access Violation When SetLength(DynArray, Value)

2022-09-08 Thread Peter B via fpc-pascal
I suggest trying without optimisations and/or using cmem, to see if that changes the outcome. Also, if the array is corrupted prior to the setlength, then iterating the array with a trivial   with... Writeln(Color) or whatever, should trigger an exception. That could then be used at various pa

Re: [fpc-pascal] Access Violation When SetLength(DynArray, Value)

2022-09-08 Thread Anthony Walter via fpc-pascal
Please ignore this post. I fixed the issue. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Access Violation When SetLength(DynArray, Value)

2022-09-08 Thread wkitty42--- via fpc-pascal
On 9/8/22 9:54 AM, Anthony Walter via fpc-pascal wrote: Please ignore this post. I fixed the issue. curious minds want to know: what was the fix? -- NOTE: No off-list assistance is given without prior approval. *Please keep mailing list traffic on the list where it belongs!* _

Re: [fpc-pascal] Access Violation When SetLength(DynArray, Value)

2022-09-08 Thread Anthony Walter via fpc-pascal
> curious minds want to know: what was the fix? In a separate part of the pool table initialization, I was precalculating the midpoints and normals for bumper rails. I had carelessly written this code: for I := 0 to Length(Rails) do RailInit(Rails[I], I); ___

[fpc-pascal] Get TMethod from function reference

2022-09-08 Thread Hairy Pixels via fpc-pascal
A function reference can call a class method but can you get the TMethod data from function references? It was possible with “is object” to cast to TMethod but that doesn’t seem to be possible with references. = type TMyClass = class constructor Create; procedure DoThis; end

Re: [fpc-pascal] Get TMethod from function reference

2022-09-08 Thread Michael Van Canneyt via fpc-pascal
On Thu, 8 Sep 2022, Hairy Pixels via fpc-pascal wrote: A function reference can call a class method but can you get the TMethod data from function references? It was possible with “is object” to cast to TMethod but that doesn’t seem to be possible with references. = type TMyClass

Re: [fpc-pascal] Get TMethod from function reference

2022-09-08 Thread Hairy Pixels via fpc-pascal
> On Sep 8, 2022, at 9:09 AM, Michael Van Canneyt > wrote: > > To me it seems logical that you cannot do this, since a function reference is > actually an > interface, and there is no actual object to back it up. > > Your function reference could also be a regular procedure (no data at all)

Re: [fpc-pascal] Get TMethod from function reference

2022-09-08 Thread Michael Van Canneyt via fpc-pascal
On Thu, 8 Sep 2022, Hairy Pixels via fpc-pascal wrote: On Sep 8, 2022, at 9:09 AM, Michael Van Canneyt wrote: To me it seems logical that you cannot do this, since a function reference is actually an interface, and there is no actual object to back it up. Your function reference could

Re: [fpc-pascal] Get TMethod from function reference

2022-09-08 Thread Hairy Pixels via fpc-pascal
> On Sep 8, 2022, at 11:14 AM, Michael Van Canneyt via fpc-pascal > wrote: > > It must keep this information somewhere, but this does not mean you can > typecast it to a TMethod. Indeed. I wonder if this information could be exposed by some method in the interface? It would be useful to int

[fpc-pascal] Why does nested function get corrupted?

2022-09-08 Thread Hairy Pixels via fpc-pascal
Curious more than anything, if is nested captures state in a record and passes it as an hidden self param, why does returning the variable and calling from outside the calling stack frame corrupt the data? It seems like it technically should be there. == type TProc = procedur