Opened 8 years ago

Closed 7 years ago

#3975 closed defect (fixed)

Incorrect evaluation of boolean vector expression in when statements

Reported by: Francesco Casella Owned by: Per Östlund
Priority: high Milestone: 2.0.0
Component: New Instantiation Version:
Keywords: Cc:

Description

Consider the following test case:

model M
  Boolean b1, b2;
  Integer i(start = 0, fixed = true);
equation
  b1 = if time > 0.1 then false else false;
  b2 = if time > 0.2 then true else false;
  when cat(1,not{b1}, not {b2}) then
    i = pre(i)+1;
  end when;
end M;

When compiling it, I get

M.c:125:69: error: incompatible types when assigning to type 'modelica_boolean {aka signed char}' from type 'boolean_array {aka struct base_array_s}'
   data->localData[0]->booleanVars[0] /* $whenCondition1 DISCRETE */ = tmp4;

Note that other boolean expressions are dealt with niceley, e.g.

model M2
  Boolean b1, b2;
  Integer i(start = 0, fixed = true);
equation
  b1 = if time > 0.1 then false else false;
  b2 = if time > 0.2 then true else false;
  when cat(1,{not b1}, {not b2}) then
    i = pre(i)+1;
  end when;
end M2;

Change History (5)

comment:1 by Martin Sjölund, 8 years ago

Milestone: 1.10.01.11.0

Ticket retargeted after milestone closed

comment:2 by Martin Sjölund, 8 years ago

Milestone: 1.11.01.12.0

Milestone moved to 1.12.0 due to 1.11.0 already being released.

comment:3 by Francesco Casella, 7 years ago

Component: Code GenerationNew Instantiation
Milestone: 1.12.02.0.0
Owner: changed from Lennart Ochel to Per Östlund
Status: newassigned

With the new front-end, OMEdit just crashes on this test case

in reply to:  3 comment:4 by Per Östlund, 7 years ago

Replying to casella:

With the new front-end, OMEdit just crashes on this test case

That was actually fixed by sjoelund.se yesterday in 76aa0b33, now it instead fails because of missing support for cat. But at least it doesn't segfault anymore.

comment:5 by Francesco Casella, 7 years ago

Resolution: fixed
Status: assignedclosed

The model M now simulates correctly with OMEdit v1.13.0-dev-113-g8c6364e6 (64-bit) connected to v1.13.0-dev-602-g4204ff08e (64-bit), when using the new FE.

Also this variant simulates correctly

model M3
  Boolean b1, b2;
  Integer i(start = 0, fixed = true);
equation
  b1 = if time > 0.1 then false else true;
  b2 = if time > 0.2 then false else true;
  when cat(1,not{b1}, not {b2}) then
    i = pre(i)+1;
  end when;
end M3;
Note: See TracTickets for help on using tickets.