[fpc-devel] Const optimization is a serious bug
Alexander Klenin
klenin at gmail.com
Tue Jul 5 20:28:30 CEST 2011
On Wed, Jul 6, 2011 at 05:12, Martin <fpc at mfriebe.de> wrote:
> TStringList could be made save, and keep the const. Just add additonal
> references where needed.
Agreed with your analysis. This still feels like a wrong design to me
-- spreading complexity
all over the place (all the libaries) instead of concenctrating it in
a single point (compiler).
Still, it seems this is yet another loosing FPC battle for me -- so
your suggestion
seems the only resort.
>
>> Note that the only reason TString/TStringList does not break too often is
>> that
>> the only way to get access to an element is by calling Get, which
>> increments refcount
>
> Not getting this part?
Suppose somebody implements "const Result" as I suggested in the link
I posted. Then the code like
strLst.DelimitedText := strLst[0];
will cause the same problem.
Alternatively, suppose somebody adds TStringList.ForEach(AVisit:
TVisitString) method,
then similar problems will be in the visitor procedure
procedure VisitString(const AStr: String);
--
Alexander S. Klenin
More information about the fpc-devel
mailing list