[fpc-devel] Inc() and Dec() on properties
sergei_gorelkin at mail.ru
Fri Dec 20 23:28:04 CET 2013
On 21.12.2013 02:11, Mark Morgan Lloyd wrote:
> Sven Barth wrote:
>> On 20.12.2013 22:02, Mark Morgan Lloyd wrote:
>>> A question if I may, leading on from
>>> > - inc(x)/dec(x) with range checking enabled are "optimized" with
>>> > taking address of x.
>>> Is that why Inc() and Dec() can't be applied to properties, or are there
>>> other issues?
> Noted, but I think my real question is whether the compiler could recognise that the optimisation is
> inappropriate and instead generate +=n (with range checking).
Yes, the compiler was recognizing case with enabled range checking and generating "x:=x+n". However
if "x" involves a function call (e.g. inc(somearray[foo()+2]); ) it is still necessary to avoid
calling it twice, hence the optimization. I used quotes because the end result was opposite to the
More information about the fpc-devel