[fpc-devel] crash with -gt -O2 in trunk

Jonas Maebe jonas.maebe at elis.ugent.be
Sat Jun 5 18:44:18 CEST 2010


On 05 Jun 2010, at 18:09, Martin wrote:

> Ok, I should say first, I do not know if it is fpc, or lazarus. At the moment I guess fpc.
> 
> It only happens in trunk (15366, also seen with earlier trunk) / rel 2.4.0 seems to be not affected
> It only happens in combination of -O2 and -gt together.
> 
> Compiled lazarus with:   -gh -gt -g -gl  -gw -godwarfsets  -O2

What about the RTL?

One common pitfall with -gt: it not only trashes local variables, but also "out" parameters. It happens from time to time that people expect "out" parameters to be unmodified if the callee doesn't modify it. Another problem is if you have something like do_assignment(const fromrec: trecord; out torec: trecord) and you call it like do_assignment(rec1,rec1). Since the torec parameter will be trashed on procedure entry and since the fromrec parameter may be passed by reference, the assigned value may become the trashed one instead of the original one.

There is at least one place in the rtl where this can happen in case it is compiled with -gt (the helper used when assigning a shortstring to another one), so in general I would recommend against compiling the rtl with -gt.


Jonas


More information about the fpc-devel mailing list