﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc
5814	for loop in algorithm section gets wrong values	r8KZbITHbJBHykci96Mg@…	Mahder Alemseged Gebremedhin	"The following example is a simple demonstration of the bug.

{{{#!modelica
connector AgentInPort
    input Real Temp;
    input Real MassFlow;
end AgentInPort;

connector AgentOutPort
    output Real Temp;
    output Real MassFlow;
end AgentOutPort;


model MyAgentAcc
    parameter Integer nports;
    AgentInPort[nports] In;
    AgentOutPort Out;
    Real sumTemp, sumMassFlow;
    Real mf[nports], te[nports];
algorithm

    for i in 1:nports loop
        te[i] := In[i].Temp;
        sumTemp := sumTemp + In[i].Temp;
        mf[i] := In[i].MassFlow;
        sumMassFlow := sumMassFlow + In[i].MassFlow;
    end for;
equation
    Out.MassFlow = sumMassFlow;
    Out.Temp = sumTemp;
end MyAgentAcc;


model Tester
    MyAgentAcc TestAcc(nports=2);
    AgentOutPort VL1, VL2;
equation
    VL1.Temp = 14;
    VL1.MassFlow = 1;
    VL2.Temp = 28;
    VL2.MassFlow = 2;
    connect(VL1, TestAcc.In[1]);
    connect(VL2, TestAcc.In[2]);
end Tester;

}}}

The expected output is:
TestAcc.Out.MassFlow = 3
TestAcc.Out.Temp = 42
TestAcc.mf[1] = 1
TestAcc.mf[2] = 2
TestAcc.te[1] = 14
TestAcc.te[2] = 28

But the output is:
TestAcc.Out.MassFlow = 15
TestAcc.Out.Temp = 16
TestAcc.mf[1] = 1
TestAcc.mf[2] = 14
TestAcc.te[1] = 14
TestAcc.te[2] = 2

In the for loop i=1 is working as expected, but with i=2 we get wrong values! 
"	defect	accepted	critical		Code Generation	v1.14.1			
