[fpc-devel] dominant short strings in compiler source

peter green plugwash at P10Link.net
Tue May 16 18:41:47 CEST 2006


how about adding a "shortstring length error" option and using it when
compiling the compiler. The compiler must be doing length checking anyway to
give clean truncation so i can't imagine this would bring a signifiant
performance penalty.

This would make bugs related to shortstring overflow much easier to trace!

> -----Original Message-----
> From: fpc-devel-bounces at lists.freepascal.org
> [mailto:fpc-devel-bounces at lists.freepascal.org]On Behalf Of Daniël
> Mantione
> Sent: 16 May 2006 17:30
> To: FPC developers' list
> Subject: Re: [fpc-devel] dominant short strings in compiler source
>
>
>
>
> Op Tue, 16 May 2006, schreef L505:
>
> > I'm really surprised about the amount of short strings used on
> the FPC compiler source,
> > such as short strings being used even to pass to Exec() when
> the linker is called on
> > windows. This is obviously why for the past few years I've had
> all sorts of chopped off
> > issues with FPC and got weird linker messages when using long
> directory paths. Especially
> > when I am using the -o option in combination with a bunch of
> other linker options
> > (since -o is passed to the linker, along with -K options and
> other stuff, such
> > as --include, AFAIK). I'm wondering why short strings were used
> so dominantly - was it
> > because FPC 2.0.x is based on old source code base which didn't
> have ansistrings available
> > yet? Was it for speed? I don't see how using short strings
> could significantly improve the
> > speed on for example an Exec call - I could see it greatly
> improving speed in some cases -
> > but when it introduces hard to find bugs, not worth a few
> milliseconds IMO. And the Pascal
> > language is supposed to have less bugs in it because of strong
> typing, but in fact strong
> > short string typing has really caused me a lot of bizarre bug
> headache :-)
> >
> > I've made some efforts to change some stuff to ansistrings to
> try and solve my bug with -k
> > option that I mentioned recently - and although I am making
> progress, I realize that I am
> > changing TONS of code since tons of the code uses short strings
> - is there any plan to get
> > rid of the short string reliance in lots of the code? It will
> require a HUGE patch on
> > multiple units. I'm just trying to find out some of your plans
> on the future FPC versions.
> > The short string reliance kind of scares me, actually.
>
> It is partially historic, but mostly for for performance reasons.
> Shortstrings are really a lot faster than ansistrings, and therefore they
> will continue to be used.
>
> While ansistrings are not really forbidden in the compiler source, there
> has never be a good reason to use ansistrings in a lot of code.
>
> Daniël




More information about the fpc-devel mailing list