[fpc-devel] Const optimization is a serious bug

Hans-Peter Diettrich DrDiettrich1 at aol.com
Mon Jul 11 08:08:35 CEST 2011


Daniƫl Mantione schrieb:

> Within a certain calling convention, the behaviour of const is defined 
> and will not change. I.e. an int64 may be passed by value in one calling 
> convention and by ref in another, but once the calling convention is 
> fixed, future compatibily is maintained; your assembler routines can 
> safely assume the behaviour won't change.

The compiler has to implement correctly the ABI of every platform, for
compatibility with external functions. Assembler code has to be
rewritten for every target machine and ABI.

The language can only specify proprietary calling conventions (ABI),
that are bound to specific processors, so that assembler code can be
written once for every processor, regardless of the platform ABI.

The use of "const" parameters and generic types is nonsense with
assembler routines, because these are compiler specific implementation
details. I'd also ban their use in shared libraries (DLL/so), which must 
have an immutable ABI. Here's another place for the "constref" modifier.

DoDi





More information about the fpc-devel mailing list