[fpc-devel] Const optimization is a serious bug

Daniël Mantione daniel.mantione at freepascal.org
Sun Jul 10 21:40:42 CEST 2011



Op Sun, 10 Jul 2011, schreef Chad Berchek:

> I think we really cannot assume anything about what exactly will happen 
> with regard to the calling convention, which is what I was worried about 
> earlier.

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.

However, for a new calling convention (on an existing or a new platform) 
it's completely up to the compiler designer what will be passed as const 
and what will be passed as reference.

You Pascal code should be able to handle both value *and* reference. After 
all, with const you are leaving the decision to the compiler. This is what 
it means in the end. Then your Pascal code should not depend on specific 
behaviour.

Daniël


More information about the fpc-devel mailing list