[fpc-pascal] When the variable freed in Optimize compile
Flávio Etrusco
flavio.etrusco at gmail.com
Wed Jun 8 19:01:30 CEST 2011
On Wed, Jun 8, 2011 at 6:17 AM, Jonas Maebe <jonas.maebe at elis.ugent.be> wrote:
>
> On 08 Jun 2011, at 10:57, Zaher Dirkey wrote:
>
>> Hi, I know when compile the project with optimize in Delphi the variable
>> freed/allocated after the last line used.
>> How can i make same in FPC, O3 not worked for me.
>
> FPC only reuses stack slots allocated for temporary expressions. It does not
> reuse stack slots used by variables.
>
>
> Jonas
>
While we are at it, is this a limitation or by design?
> > What if C is string or Interface of TInterfacedObject?
> It is the same logic. It's freed only at the end.
I recently noticed that this is also true for ansistrings. I see this
can avoid lots of errors, but also makes it very ackward to
intentionally avoid copies when modifying strings in-place if they are
obtained from a function...
-Flávio
More information about the fpc-pascal
mailing list