[fpc-pascal] Error: Local variables size exceeds supported limit

Yuriy Sydorov jura at cp-lab.com
Sun Mar 10 13:15:14 CET 2019


On 10.03.2019 13:48, Jonas Maebe wrote:
> On 10/03/2019 11:40, Yuriy Sydorov wrote:
>> If I recall correctly, currently the compiler uses longints as stack offsets internally in several places. That's why 
>> the limit is 2GB even for 64-bit targets.
> 
> That would be compiler bugs that need to be fixed. Ideally, the commit message would also have mentioned that :)

Sure :)
I've checked it right now. Indeed the compiler uses longint values as the stack offsets here and there. It need to be 
fixed in order to support 64-bit offsets. Earlier versions of FPC simply does not contain the proper checks and does not 
throw en error for local vars exceeding 2GB. But the resulting generated code is broken anyway. So no regression here.

>> I suppose there are no real world apps which require 2GB of stack for local vars or parameters. Even if we consider 
>> future apps it is useless to support 64-bit stack offsets for local vars of a single procedure.
> 
> If the architecture and OS support it, I see no reason to forbid it. It's always possible to add a hint about efficiency 
> in case the size of the locals grows beyond offsets that can be embedded in a single instruction, although this hint 
> would trigger already at 32KB of locals on e.g. PowerPC.

Sure, if someone would volunteer to implement this :)

ARM also requires several instructions for offsets larger than 4KB and this is normal. Therefore the hint should be 
issued only for huge offsets related to the bitness of a target CPU. The warning would be even better, since in most 
cases usage of huge local vars/params means a bug or not desired effect, such as discussed in this topic.

Yuriy.



More information about the fpc-pascal mailing list