[fpc-devel] Const optimization is a serious bug
    José Mejuto 
    joshyfun at gmail.com
       
    Tue Jul  5 19:27:41 CEST 2011
    
    
  
Hello FPC,
Tuesday, July 5, 2011, 6:44:24 PM, you wrote:
JM> Since the behaviour of "const" for automated types is
JM> explicitly defined by Borland as not causing any changes in
JM> reference counting (see the note at the bottom of
JM> http://docwiki.embarcadero.com/RADStudio/en/Using_Reference_Counting
JM> ), I think Martin/Florian's proposal to add the ability for adding
JM> extra compiler checks is best. It's similar to how range and
JM> overflow checking are optional.
But adding a checksum over allocated data or only over control data ?
This changes should be detected ?
var
  a: ansistring;
  
procedure DoSomehting(const v: ansistring);
begin
  a[1]:='a';
end;
begin
  a:='b';
  DoSomething(a);
end.
Maybe "simply" add a constRefCount field which is only used with the
check automagic types turned on ? Anyway the worst behaviour is
refcount related do not ? If refcount should be updated and the
variable have a constRefCount>0 then something went wrong. Also this
mode should not impose a serious performance penalty.
-- 
Best regards,
 José
    
    
More information about the fpc-devel
mailing list