Open Array vs Dyn Array as argument type in functions, changes in FPC 3.3 lazarus / 62-General ---------------------------------------------------------------------- prof7bit · 2021-09-23 10:07 Consider this: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i program Project1; type  TBytes = array of Byte; procedure Foo(A: array of Byte);beginend; procedure Bar(A: TBytes);beginend; var  X: array[0..15] of Byte; begin  Foo(X);  Bar(X); // error in FPC 3.3.1, compiles fine in 3.2.1end.  The above code has been compiling and working fine in FPC 3.2 but it fails to compile in FPC main. The error is: Incompatible type for arg no. 1: Got "Array[0..15] Of Byte", expected "TBytes" Is this intentional? Was the previous behavior a bug? I can vaguely remember being mildly surprised when I found out that I can use it like in the code above, but then did not spend any more thoughts on it. ---------------------------------------------------------------------- marcov · 2021-09-23 10:20 I don't know, but if you look at the 3.2.x assembler, it effectively seems to create a TBytes temp, and this is indeed not very nice: Code: [Select] leal -4(%ebp),%eax movl $RTTI_$P$PROJECT1_$$_TBYTES,%edx call fpc_dynarray_clear movl $16,-8(%ebp) leal -8(%ebp),%eax pushl %eax movl $RTTI_$P$PROJECT1_$$_TBYTES,%edx movl $1,%ecx leal -4(%ebp),%eax call fpc_dynarray_setlength movl -4(%ebp),%edi movl $U_$P$PROJECT1_$$_X,%esi movl $4,%ecx rep movsl movl -4(%ebp),%eax call P$PROJECT1_$$_BAR$TBYTES ---------------------------------------------------------------------- PascalDragon · 2021-09-23 11:28 Quote from: prof7bit on September 23, 2021, 12:07:33 pmThe above code has been compiling and working fine in FPC 3.2 but it fails to compile in FPC main. The error is: Incompatible type for arg no. 1: Got "Array[0..15] Of Byte", expected "TBytes" Is this intentional? Was the previous behavior a bug? I can vaguely remember being mildly surprised when I found out that I can use it like in the code above, but then did not spend any more thoughts on it. Yes, this is intentional and documented.