Interesting issue. I have tried this and found that FPC 3.0.0 generates a compile error "Assignments to formal parameters and arrays are not possible", but the error does not appear if the call to f is made from within a while loop. Odd. {$mode objfpc}procedure f(arr: array of ShortInt);begin while true do //uncommenting the while makes the difference f(arr[0]);end;
<?xml version="1.0" encoding="UTF-8"?><CONFIG> <ProjectOptions> <Version Value="9"/> <PathDelim Value="\"/> <General> <Flags> <MainUnitHasCreateFormStatements Value="False"/> <MainUnitHasTitleStatement Value="False"/> </Flags> <SessionStorage Value="InProjectDir"/> <MainUnit Value="0"/> <Title Value="Project1"/> <UseAppBundle Value="False"/> <ResourceType Value="res"/> </General> <i18n> <EnableI18N LFM="False"/> </i18n> <VersionInfo> <StringTable ProductVersion=""/> </VersionInfo> <BuildModes Count="1"> <Item1 Name="Default" Default="True"/> </BuildModes> <PublishOptions> <Version Value="2"/> </PublishOptions> <RunParams> <local> <FormatVersion Value="1"/> </local> </RunParams> <Units Count="1"> <Unit0> <Filename Value="Project1.pas"/> <IsPartOfProject Value="True"/> </Unit0> </Units> </ProjectOptions> <CompilerOptions> <Version Value="11"/> <PathDelim Value="\"/> <Target> <Filename Value="Project1"/> </Target> <SearchPaths> <IncludeFiles Value="$(ProjOutDir)"/> <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/> </SearchPaths> <CodeGeneration> <Optimizations> <OptimizationLevel Value="2"/> </Optimizations> </CodeGeneration> <Linking> <Debugging> <GenerateDebugInfo Value="False"/> </Debugging> </Linking> </CompilerOptions> <Debugging> <Exceptions Count="3"> <Item1> <Name Value="EAbort"/> </Item1> <Item2> <Name Value="ECodetoolError"/> </Item2> <Item3> <Name Value="EFOpenError"/> </Item3> </Exceptions> </Debugging></CONFIG>
fpc -CX -XXs -O4 tests.pasFree Pascal Compiler version 3.1.1-r35333 [2017/01/26] for armCopyright (c) 1993-2017 by Florian Klaempfl and othersTarget OS: Linux for ARMHFCompiling tests.pastests.pas(5,1) Error: Assignments to formal parameters and open arrays are not possibletests.pas(16) Fatal: There were 1 errors compiling module, stoppingFatal: Compilation abortedError: /usr/local/bin/ppcarm returned an error exitcode
fpc -CX -XXs -O4 tests.pasFree Pascal Compiler version 3.1.1-r35333 [2017/01/26] for armCopyright (c) 1993-2017 by Florian Klaempfl and othersTarget OS: Linux for ARMHFCompiling tests.pastests.pas(14,6) Warning: Variable "a" does not seem to be initializedLinking tests