[fpc-devel] Erroneous finalizing of const widestring array

Marco van de Voort marcov at stack.nl
Sun Jul 1 13:52:13 CEST 2007


> Op Sun, 1 Jul 2007, schreef Martin Schreiber:
> 
> The main issue with extra string types is that the number of possible 
> conversions is n*n-n. With 2 string types you need to handle just 2 
> conversions. With the current 3, we have 3*3-3=6 conversions. With 4, it 
> becomes 12 conversions.

3?

My count:

  (Possible) Delphi string types and types that auto converted to them in
some
form or the other:

- 1 (ansi)char
- 1 wide char,   (both = char and widechar from now on)
- 2 (static) array of both
- 2 dynamic array of both. 
- 2 open array of both, 
- 2 pointer to both, 
- 2 pointer to array of both , 
- 3 short,ansi,widestring types.
- 1 open array shortstring.
----
  16 (FPC or Delphi/Kylix combined one more because of refcounted,
  non olewidestring)

Note that I didn't test all this. It was just what I could quickly think up.

Theoretic maximal number of conversions: 16*16 = 256

This is way too high of cousre:
- assumes every conversion is possible (some like open arrays are possibly
readonly), 
- assumes every conversion reversable.  
- also 16 direct assignments to same type are included, which are less prone
to automatic conversion problems.

Some other remarks gathered from the various comments (IRC and
c.l.p.delphi.misc)

- Note that this even does not include some of these types in variants.
- literals. Are string literals different ? 
	- Are the more types of literals?
	- are there conversions, not over the base string types between
	literals and e.g. static array of char?




More information about the fpc-devel mailing list