[fpc-devel] Const optimization is a serious bug
Wimpie Nortje
wimpienortje at gmail.com
Thu Jul 7 14:57:03 CEST 2011
> 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.
> As soon as you understand this subtle difference, the problem disappears.
My suggestion is that the gist of the documentation be changed from "Use
const strings, it is good for you" to "Const strings are powerful. They
are also dangerous. Don't use it unless you really really understand them"
More information about the fpc-devel
mailing list