On 01/11/2013 15:10, Tomas Hajny wrote:
Sorry if I overlooked something, but where is the variable of that type declared in your code? These objects may be either declared statically ("var B: TBar") or dynamically ("Result := New (TBar.Init)" - but then the return value must be of type PBar, not TBar).
Objects are like (advanced) records.
So Result is a TBar, and result already has the memory it needs. "New" is not needed.
If I understand it correctly, you initialize the object on the stack, but it would disappear from there (gets overwritten) immediately after the function return (the following function call would overwrite it).
It gets lost only, because i do not use the result of the function call. But even if D did "SomVarBar := Foo;", I still get the warning. _______________________________________________ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel