[fpc-devel] Const optimization is a serious bug
Thaddy
thaddy at thaddy.com
Tue Jul 5 13:04:27 CEST 2011
On 5-7-2011 12:34, Felipe Monteiro de Carvalho wrote:
> Maybe the compiler should start issuing hints or warnings for all
> places where one uses const with ansistring, so that people who don't
> care about the speed advantage can start removing those const
> ansistrings from their code base.
>
Yes, but is is no bug! It is a contract between the compiler and the
programmer in which it is expected that the string will not be modified
inside a procedure, function or method.
That is also part of the speed optimization: the compiler doesn't have
to check because of this contract. This is also the case in many other
languages.
More information about the fpc-devel
mailing list