[fpc-pascal] Porter Stemming for FPC 2.0

memsom memsom at interalpha.co.uk
Sat Sep 17 01:55:15 CEST 2005


> It's great that 2.0 is out!  Unfortunately it seems to break some
> code I used for Porter Stemming because the code sometimes reads data
> from a pchar at negative indexes.  Reportedly this works fine in
> Delphi 5 and I don't seem to have trouble with Delphi 7 but it
> generates RTEs using fpc 2.0.  (If this is a FAQ, forgive me, I've
> been away from Free Pascal for a while...)

Reading PChars at negative indexes? Buffer underrun in other words... This
is absolutely not a good thing. If FPC is preventing buffer under and
overrruns, then it is actually right, for once, and Delphi is wrong,
wrong, wrong!

A question... how do you know the memory at the negative index is valid?
Various factors (memory management, record alignement and poor consistency
in longterm projects) can alter what you are reading drastically. Even if
you *believe* you know what it is. This is the kind of horror story I see
sometimes in Legacy code that makes me wonder how the darn thing _ever_
worked all these years. You ask the guy maintaining it and he goes all
mistical - "It just works, but no one remembers why.. we dare not change
it because last time somebody did anything to it the entive project A/V'd
every 30 seconds and died in a puff of green smoke."

M

M




More information about the fpc-pascal mailing list