TIniFiles and $H+ issue

Michael Van Canneyt michael.vancanneyt at wisa.be
Thu Apr 29 11:24:57 EDT 1999




On Thu, 29 Apr 1999, Michael A. Hess wrote:

> Greetings,
> 
> OK Michael now you have me confused. The more I thought about it, I
> don't understand. You indicated that TIniFiles needed to have $H+ set
> and then things worked with the TStringList.Add(''); problem.
> 
> Why?
> 
> Shouldn't it have worked without TIniFiles being set with $H+. TIniFiles
> didn't specifically use longstrings anyplace. If I made a shortened
> version of TIniFiles with less features then the Add worked correctly. I
> hadn't added the $H+. The test program you wrote which just talked to
> TStringList the same way that TIniFiles does didn't have $H+ and it
> still worked. Why would the fact that the amount of code in TIniFiles
> was greater cause it to not work? Does this mean that any code that is
> written to use TStringList or any of the FCL should have $H+ set? If
> TIniFiles passed a space (' ') instead of the empty string ('') then
> everything worked perfectly. Why did passing the empty string make a
> difference?

Good question. I understand that there is a bug somewhere, but I
haven't been able to find the 'minimal code snippet' to produce
the error.

Technically speaking, what happened is:
Normally, a empty ansistring is a nil pointer;
For some reason, your code passed (don't know how) pointer to #0
which is, strictly speaking, NOT equal to an empty string.
(although it is if you use a pchar)

This got the internal ansistring code of the RTL confused, hence
the error.

But, like I said, I didn't find the minimal code that produces
this bug :(

Michael.






More information about the Lazarus mailing list