Opened 9 years ago

Closed 9 years ago

Last modified 8 years ago

#3687 closed defect (fixed)

Inline module fails with protected array variables

Reported by: wbraun Owned by: wbraun
Priority: blocker Milestone: 1.9.4
Component: Backend Version: v1.9.4-dev-nightly
Keywords: Cc: vitalij

Description (last modified by wbraun)

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 Changed 9 years ago by wbraun

  • Description modified (diff)
  • Priority changed from high to blocker

comment:2 Changed 9 years ago by wbraun

  • Description modified (diff)

comment:3 Changed 9 years ago by lochel

  • Milestone changed from Future to 1.9.4

There should be a milestone for blockers.

comment:4 Changed 9 years ago by wbraun

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

Fixed in 7e414c9.

comment:5 Changed 8 years ago by sjoelund.se

  • Milestone changed from 1.9.4 to 1.9.4-1.9.x

Milestone renamed

comment:6 Changed 8 years ago by sjoelund.se

  • Milestone changed from 1.9.4-1.9.x to 1.9.4

Milestone renamed

Note: See TracTickets for help on using tickets.