diff --git a/.gitattributes b/.gitattributes index 26078606a7..082db01626 100644 --- a/.gitattributes +++ b/.gitattributes @@ -9766,6 +9766,7 @@ tests/test/talign2.pp svneol=native#text/plain tests/test/targ1a.pp svneol=native#text/plain tests/test/targ1b.pp svneol=native#text/plain tests/test/tarray1.pp svneol=native#text/plain +tests/test/tarray10.pp svneol=native#text/plain tests/test/tarray2.pp svneol=native#text/plain tests/test/tarray3.pp svneol=native#text/plain tests/test/tarray4.pp svneol=native#text/plain diff --git a/compiler/ncgcal.pas b/compiler/ncgcal.pas index 8a52b887f3..5e91f1b09f 100644 --- a/compiler/ncgcal.pas +++ b/compiler/ncgcal.pas @@ -169,11 +169,16 @@ implementation location_get_data_ref(current_asmdata.CurrAsmList,left.location,href,false,sizeof(pint)); if is_open_array(resultdef) then begin - if third=nil then - InternalError(201103063); - secondpass(third); - cg.g_array_rtti_helper(current_asmdata.CurrAsmList,tarraydef(resultdef).elementdef, - href,third.location,'FPC_DECREF_ARRAY'); + { if elementdef is not managed, omit fpc_decref_array + because it won't do anything anyway } + if is_managed_type(tarraydef(resultdef).elementdef) then + begin + if third=nil then + InternalError(201103063); + secondpass(third); + cg.g_array_rtti_helper(current_asmdata.CurrAsmList,tarraydef(resultdef).elementdef, + href,third.location,'FPC_DECREF_ARRAY'); + end; end else cg.g_decrrefcount(current_asmdata.CurrAsmList,left.resultdef,href); diff --git a/tests/test/tarray10.pp b/tests/test/tarray10.pp new file mode 100644 index 0000000000..c848845aa7 --- /dev/null +++ b/tests/test/tarray10.pp @@ -0,0 +1,18 @@ +{$mode objfpc}{$h+} + +procedure SetArray(out SingleArray: array of Single; const Value: Single); +var + I: Integer; +begin + for I := Low(SingleArray) to High(SingleArray) do + SingleArray[I] := Value; +end; + +var + ValuesBuffer: array of Single; + +begin + SetLength(ValuesBuffer, 5); + { passing to should not trigger IE 201103063 } + SetArray(ValuesBuffer, 5.7); +end.