[fpc-devel] Const optimization is a serious bug

michael.vancanneyt at wisa.be michael.vancanneyt at wisa.be
Thu Jul 7 15:14:52 CEST 2011



On Thu, 7 Jul 2011, Wimpie Nortje wrote:

>
>> Based on this promise, the compiler may decide to do some optimization.
>> It will also warn you if it detects inside the code that you break
>> your promise.
> Based on my new knowledge of const strings I revisited the bug I
> mentioned previously. I still have no idea where exactly I made the
> error. And I never got a warning about the promise being broken.
>
> For me the advantages of using const strings are completely dwarfed by
> the time required to ensure I keep my side of the promise and still have
> the risk that some small change in the future will break it without
> causing compiler warnings.

Well, I program FPC and Delphi since many many years, in a multithreaded
server environment, and have never encountered a problem with this.

Given this, and the IMHO convoluted examples that were used to show the
'problem', I'm inclined to say that you must be writing some pretty 
strange code to have encountered this problem.

Given that Borland never decided to 'fix' it, I'm inclined to think that
they also don't consider it a real problem, but rather a corner case
(if they are aware of it at all).

That of course doesn't alter the fact that a corner case can seriously
bite you in the leg. I've had such cases as well. I just shrugged and
fixed my code.

C'est la vie.

Michael.



More information about the fpc-devel mailing list