Opened 10 years ago

Closed 9 years ago

Last modified 7 years ago

#3047 closed defect (fixed)

invalid c code for array in algorithm

Reported by: lochel Owned by: lochel
Priority: high Milestone: 1.9.4
Component: Code Generation Version: trunk
Keywords: Cc: mahge930

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 Changed 10 years ago by lochel

  • Cc mahge930 added

comment:2 Changed 9 years ago by mahge930

  • Resolution set to fixed
  • Status changed from new to closed

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

comment:3 Changed 9 years ago by dietmarw

  • Milestone changed from Future to pre1.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 Changed 7 years ago by sjoelund.se

  • Milestone changed from pre1.9.4 to 1.9.4

Removing the pre1.9.4 milestone in favor of 1.9.4.

Note: See TracTickets for help on using tickets.