﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc
6172	Issue with for loop index variables in conditional expression within algorithm	Francesco Casella	Mahder Alemseged Gebremedhin	"Consider the following test model

{{{#!mo
class matrixAdd
  parameter Real[3,2] m={{1,2},{2,3},{4,5}};
  parameter Real[3,2] a={{2,2},{2,2},{2,2}};
  Real[3,2] b;
  Real max;
algorithm
  max:=0;
  for i in 1:3 loop
    for j in 1:2 loop
      b[i,j]:=m[i,j]+a[i,j];
      if (max<b[i,j]) then
          max:=b[i,j];
      end if;
    end for;
  end for;
end matrixAdd;
}}}
It causes the C compilation to break with
{{{#!c
matrixAdd_05evt.c: In function 'matrixAdd_function_ZeroCrossings':
matrixAdd_05evt.c:51:161: error: 'i' undeclared (first use in this function)
   tmp0 = LessZC(data->localData[0]->realVars[6] /* max variable */, (&data->localData[0]->realVars[0] /* b[1,1] variable */)[calc_base_index_dims_subs(2, 3, 2, i, ((modelica_integer) 1))], data->simulationInfo->storedRelations[0]);
                                                                                                                                                                 ^
matrixAdd_05evt.c:51:161: note: each undeclared identifier is reported only once for each function it appears in
matrixAdd_05evt.c: In function 'matrixAdd_function_updateRelations':
matrixAdd_05evt.c:78:163: error: 'i' undeclared (first use in this function)
     tmp2 = LessZC(data->localData[0]->realVars[6] /* max variable */, (&data->localData[0]->realVars[0] /* b[1,1] variable */)[calc_base_index_dims_subs(2, 3, 2, i, ((modelica_integer) 1))], data->simulationInfo->storedRelations[0]);
}}}"	defect	accepted	high		Code Generation				gptshubham595@…
