The actual problem is not so much as a pointer being returned because that isn't really what is happening, the whole object is copied over from the stack if you do a local test..
So initially a background copy is created on the stack, executed and a copy is stored in the resulting variable is that is how it's being used at the time.. Because there is no memory leaks otherwise... The issue is the use of the managed Array that is being used. the system is cleaning it up on exit if not being made a copy of first.. Just one of those Managed things I guess.. Because if you use a non-managed array its still living when exiting the constructor.
Hahaha... Blaazen was right. I should have written aLoop := RaLoop.Create(100, 2, [3,6,9]); instead of aLoop.Create(100, 2, [3,6,9]);I made similar mistakes several times (with class, not records), and still am making the same mistakes.
Though in all fairness, the second one should work as well, as in Delphi it works without problems. It might be due to the way record constructors are implemented in FPC. I'll probably need to change that anyway so that we can support them in New as well.