Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#3687 closed defect (fixed)

Inline module fails with protected array variables

Reported by: Willi Braun Owned by: Willi Braun
Priority: blocker Milestone: 1.9.4
Component: Backend Version: v1.9.4-dev-nightly
Keywords: Cc: Vitalij Ruge

Description (last modified by Willi Braun)

Following model results into code generation issue, because of protected array variables:

model foo
  function f
    input Real z;
    output Real y;
  protected
    Real a[2];
  algorithm
    a := {2 * z, z};
    y := sum(a);
    annotation(Inline = true);
  end f;

  Real y(start = 0, fixed = true);
  Real z;
equation
  z = f(5 + time);
  der(y) = z;
end foo;

Even worse is the following example:

model foo
  function f
    input Real z;
    output Real y;
  protected
    Real a[2];
  algorithm
    a := {2 * z, z};
    y := sum(a)/3;
    annotation(Inline = true);
  end f;
  function f1
    input Real z;
    output Real y;
  protected
    Real a[2];
  algorithm
    a := {2 * z, z};
    y := sum(a)/3;
  end f1;

  Real y(start = 0, fixed = true);
  Real z, z2;
  Real a[2] = {sin(time),cos(time)};
equation
  z = f(5 + time);
  z2 = f1(5 + time);
  der(y) = z;
end foo;

that results into really wrong outcome for z compared to z2.

Change History (6)

comment:1 by Willi Braun, 9 years ago

Description: modified (diff)
Priority: highblocker

comment:2 by Willi Braun, 9 years ago

Description: modified (diff)

comment:3 by Lennart Ochel, 9 years ago

Milestone: Future1.9.4

There should be a milestone for blockers.

comment:4 by Willi Braun, 9 years ago

Resolution: fixed
Status: newclosed

Fixed in 7e414c9.

comment:5 by Martin Sjölund, 9 years ago

Milestone: 1.9.41.9.4-1.9.x

Milestone renamed

comment:6 by Martin Sjölund, 9 years ago

Milestone: 1.9.4-1.9.x1.9.4

Milestone renamed

Note: See TracTickets for help on using tickets.