﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc
3047	invalid c code for array in algorithm	Lennart Ochel	Lennart Ochel	"OMC generates invalid code for the following model:
{{{#!mo
model foo
  block goo
    input Integer N;
    output Real r[10];
    output Integer i[10];
    output Real y;
  algorithm
    i :=zeros(10);
    for j in 1:10 loop
      r[j] :=j;
      if j <= N then
        i[j] :=j;
      end if;
    end for;

    y :=sum(r[i[1:N]]);
  end goo;

  Integer N;
  goo g(N=N);
initial equation
  N = 0;
equation
  when sample(0.1, 0.1) then
    N = pre(N)+1;
  end when;
end foo;
}}}

The error message is {{{error: ‘$Pg$PN’ undeclared}}}.
The generated c code contains following statements at the end of the algorithm of block goo:
{{{#!c
real_array_create(&tmp6, ((modelica_real*)&($Pg$Pr)), 1, $Pg$PN);
$Pg$Py = sum_real_array(tmp6);
}}}
"	defect	closed	high	1.9.4	Code Generation	trunk	fixed		Mahder Alemseged Gebremedhin
