﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc
2031	indexed_assign_real_array fails	Christian Schubert	Martin Sjölund	"Hi,

I have a supposedly simple model which crashes during simulation.
The models intention was to check whether Modelica.Matrices.solve works, but we don't get this far ...
{{{
model TestSolve
	Real A[5,5]={{-725/100,-875/100,0,-5,0},{-875/100,-125/10,0,-56/10,8/10},{0,0,-5,24/10,-32/10},{-5,-56/10,24/10,0,0},{0,8/10,-32/10,0,0}};
	Real B[5,7]={{-15/10,0,2,0,-875/100,0,-1762/100},{-3,0,2,0,-125/10,0,-1762/100},{-2,0,0,0,-5,0,0},{0,0,0,0,0,0,6/10},{0,0,0,0,0,0,45/100}};
	Real X1[5,7];
	Real X2[5,7];
	Real XRef[5,7]={{-(32/41),0,0,0,-(80/41),0,-(15/41)},{32/41,0,0,0,80/41,0,117/656},{8/41,0,0,0,20/41,0,-(63/656)},{27/410,0,-(2/5),0,191/164,0,1227497/328000},{303/820,0,-(3/10),0,549/328,0,1939683/656000}};
	Real d1[5,7]=X1-XRef;
	Real d2[5,7]=X2-XRef;
	Real err1=sum(d1.*d1) ""Error 1"";
	Real err2=sum(d2.*d2) ""Error 2"";
algorithm
	for i in 1:7 loop
		X1[:,i]:=Modelica.Math.Matrices.solve(A,B[:,i]);
	end for;
	X2 := Modelica.Math.Matrices.solve2(A,B);
end TestSolve;
}}}

The problem occurs in eqFunction_134, where it tries to execute the for loop. In there we have the following lines of code
{{{
      tmp32 = omc_Modelica_Math_Matrices_solve(tmp30, tmp31);

      create_index_spec(&tmp33, 2, (1), (int*)0, 'W', (0), make_index_array(1, (int) (modelica_integer)$Pi), 'S');
      indexed_assign_real_array(&tmp32.c1, &tmp34, &tmp33);
      copy_real_array_data_mem(&tmp34, &$PX1);
}}}

Now, as this is the first usage of tmp34, the function indexed_assign_real_array fails because of the assertion
{{{
Assertion failed: base_array_ok(dest), file util/real_array.c, line 320
}}}
"	defect	closed	high	1.9.1	Code Generation	trunk	worksforme	code generation for loop	Adrian Pop Jens Frenkel
