Opened 10 years ago

Closed 10 years ago

Last modified 7 years ago

#3047 closed defect (fixed)

invalid c code for array in algorithm

Reported by: Lennart Ochel Owned by: Lennart Ochel
Priority: high Milestone: 1.9.4
Component: Code Generation Version: trunk
Keywords: Cc: Mahder Alemseged Gebremedhin

Description

OMC generates invalid code for the following model:

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:

real_array_create(&tmp6, ((modelica_real*)&($Pg$Pr)), 1, $Pg$PN);
$Pg$Py = sum_real_array(tmp6);

Change History (4)

comment:1 by Lennart Ochel, 10 years ago

Cc: Mahder Alemseged Gebremedhin added

comment:2 by Mahder Alemseged Gebremedhin, 10 years ago

Resolution: fixed
Status: newclosed

I think this was fixed by r24667. It is working now.

comment:3 by Dietmar Winkler, 9 years ago

Milestone: Futurepre1.9.4

It doesn't make sense to keep closed ticket in the "Future" milestone that were simply forgotten to assign to the correct milestone in the past.

comment:4 by Martin Sjölund, 7 years ago

Milestone: pre1.9.41.9.4

Removing the pre1.9.4 milestone in favor of 1.9.4.

Note: See TracTickets for help on using tickets.