[fpc-devel] Question on updating FPC packages

Sven Barth pascaldragon at googlemail.com
Sat Oct 26 19:02:16 CEST 2019


Am 26.10.2019 um 18:51 schrieb J. Gareth Moreton:
> The "const" suggestion was made by a third party, and while I went out 
> of my way to ensure the functions aren't changed in Pascal code, 
> Florian pointed out that it could break existing assembler code. Maybe 
> I'm being a bit stubborn or unreasonable, I'm not sure, but in my 
> eyes, using assembly language to directly call the uComplex functions 
> and operators seems rather unrealistic.  I figured if you're writing 
> in assembly language, especially if you're using vector registers, 
> you'd be using your own code to play around with complex numbers.  
> Plus I figured that if you're developing on a non-x86_64 platform, the 
> only thing that's different are the 'const' modifiers, which I don't 
> think changes the way you actually call the function, regardless of 
> platform.  Am I right in this?

It totally depends on how "const" is implemented for the particular 
target. On some there might not be any difference on others there might 
be a similar difference as for x86, namely that something is passed as a 
reference instead of a copy.

> I guess a more fundamental question I should ask, and this might be 
> terribly naïve of me, is this: when you call some function F(x: 
> TType), is there a situation where calling F(const x: TType) produces 
> different machine code or where a particular actual parameter becomes 
> illegal? Note I'm talking about how you call the function, not how the 
> function itself is compiled.

Didn't you provide the example yourself with your changes to the 
uComplex unit? There are cases (especially with records) where "x" is 
passed as a copy on the stack and "const x" is passed as a reference.

Regards,
Sven


More information about the fpc-devel mailing list