[fpc-devel] Closures -- debug warning @ ttgobj.FreeTemp

Blaise at blaise.ru Blaise at blaise.ru
Tue Mar 10 14:29:59 CET 2015

On 10.03.2015 15:47, Jonas Maebe wrote:

> Do you already have an svn account?

The one I had back in 2012.
My old branch is here: http://svn.freepascal.org/svn/fpc/branches/blaise/closures

> It indicates a problem in the compiler.

Shall I file it in the bug tracker, then?

> As the message indicates, it means that you (or someone else before you) are trying to free a temp (allocated via tg.gettemp or the like) twice.

I am slightly confused by your choice of the pronoun, so allow me to reiterate: the issue exists in the "stock" compiler, even without my patches applied.

> The generated code will still be ok in this case, but it could lead to trouble in case a temp would be allocated again in between which would happen to get the same address as the old one, since then the second free of the old temp will free the new temp.

I am not at all familiar with this part of the compiler, so devising a test case, that would result in invalid codegen, would be difficult for me.
Based on your explanation, it seems it would be something like
	Foo().Bar( YieldAnotherTemp() )
assuming that YieldAnotherTemp() is called after Foo()?


More information about the fpc-devel mailing list