[fpc-devel] Const optimization is a serious bug

Jonas Maebe jonas.maebe at elis.ugent.be
Sat Jul 9 18:43:11 CEST 2011


On 09 Jul 2011, at 18:41, Jonas Maebe wrote:

> That part of the manual is wrong. What const does is by design completely implementation-dependent (except for cdecl/cppdecl routines, where it behaves the same as in C/C++, and for mwpascal routines, where it behaves the same as in MetroWerks Pascal). And yes, this is different from the meaning of const C and C++ (which is why the meaning is specified separately there). And yes, this means that it can be unsafe if you pass global variables as const and the modify them in the called routine, and that every objection voiced already 10 times in this thread applies. That is how const has always worked since it was introduced in Turbo Pascal. And no, that does not mean this is ideal, but rewriting the entire const handling is not going to happen.

And yes, that should all be mentioned in the manual.


Jonas


More information about the fpc-devel mailing list