View Issue Details

IDProjectCategoryView StatusLast Update
0037443FPCCompilerpublic2020-08-04 14:02
ReporterIgor Kokarev Assigned ToJonas Maebe  
Status resolvedResolutionfixed 
PlatformApple SiliconOSmacOS 
Fixed in Version3.3.1 
Summary0037443: Compilation problem for aarch64-darwin-cocoa
DescriptionFPC Trunk for macOS AARCH64 can't compile attached test project with O2 code optimization or higher.

It fails on line:

Row_Buffer[RowUsed][Col] := (Row_Buffer[RowUsed][Col] + (left + above) div 2) and 255;

"Error: /Users/igor/armtest/lib/aarch64-darwin/testarm.s:49:7: error: invalid operand for instruction
Error: Error while assembling exitcode 1"

No problem with O0 or O1 code optimizations.

8964Lazarus 2.1.0 r63630 FPC 3.3.1 aarch64-darwin-cocoa
Steps To Reproduceprogram testarm;
{$ifdef fpc}{$mode Delphi}{$endif}

  TByteArray = Array[Word] of Byte;
  PByteArray = ^TByteArray;

procedure Test;
  Row_Buffer : array[Boolean] of PByteArray;
  Col : Cardinal;
  left, above : Integer;
  RowUsed : Boolean;
  Row_Buffer[RowUsed][Col] := (Row_Buffer[RowUsed][Col] + (left + above) div 2) and 255;
  Test; WriteLn;
  Write('Press ENTER to Exit'); ReadLn;
Additional InformationThis problem occurs only with AARCH64 compiler on Apple DTK.

Also this code compiles fine for x86-64 on Windows 10 and macOS with Intel CPU.
TagsNo tags attached.
Fixed in Revision
Attached Files


duplicate of 0037427 resolvedFlorian aarch64 compiler creates invalid code for implicit int64 to byte cast with -O1 and {$Q+} 


Igor Kokarev

2020-07-29 09:53

reporter (1,458 bytes)

Bart Broersma

2020-07-29 10:45

reporter   ~0124376

This is a problem with the compiler, not with Lazarus.
Please take care in which Project you post your issues.

Igor Kokarev

2020-07-29 10:49

reporter   ~0124377

Thanks, my mistake. Thanks for moving to FPC project.

Dmitry Boyarintsev

2020-07-29 22:09

developer   ~0124404

adding a relationship per Jonas' note (,50476.msg371686.html#msg371686)
for the ease of tracking in the bugtracker

Igor Kokarev

2020-07-30 09:47

reporter   ~0124410

I confirm that latest SVN version fixed this problem on Apple Silicon.

Issue History

Date Modified Username Field Change
2020-07-29 09:53 Igor Kokarev New Issue
2020-07-29 09:53 Igor Kokarev File Added:
2020-07-29 10:45 Bart Broersma Note Added: 0124376
2020-07-29 10:45 Bart Broersma Project Lazarus => FPC
2020-07-29 10:49 Igor Kokarev Note Added: 0124377
2020-07-29 22:08 Dmitry Boyarintsev Relationship added related to 0037427
2020-07-29 22:09 Dmitry Boyarintsev Note Added: 0124404
2020-07-30 09:47 Igor Kokarev Note Added: 0124410
2020-07-31 20:13 Jonas Maebe Assigned To => Jonas Maebe
2020-07-31 20:13 Jonas Maebe Status new => resolved
2020-07-31 20:13 Jonas Maebe Resolution open => fixed
2020-07-31 20:13 Jonas Maebe Fixed in Version => 3.3.1
2020-07-31 20:13 Jonas Maebe FPCTarget => -
2020-07-31 20:13 Jonas Maebe Relationship replaced duplicate of 0037427