Opened 11 years ago

Closed 3 years ago

#2214 closed defect (fixed)

code generation for iteration variable

Reported by: Lennart Ochel Owned by: Per Östlund
Priority: high Milestone: 1.19.0
Component: Code Generation Version: trunk
Keywords: Cc: Lennart Ochel, Willi Braun

Description

I found some issues using blocks. OpenModelica cannot simulate the model test from the following package.

package bug_2213
  block anyChange "does any entry of a boolean vector change its value?"
    input Boolean vec[:];
    output Boolean anychange;
  algorithm
    anychange:=false;
    for i in 1:size(vec, 1) loop
      anychange:=anychange or change(vec[i]);
    end for;
  end anyChange;

  model test
    Boolean b[3];
    anyChange ac(vec=b);
    Integer i(start=0, fixed=true);
  equation
    b[1] = time > 0.1;
    b[2] = time > 0.2;
    b[3] = time > 0.3;

    when ac.anychange then
      i = pre(i) + 1;
    end when;
  end test;
end bug_2213;

(see also #2213)

The issue is that we get in conflict with the variable name i in the generated c-code.

Change History (12)

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

This is an old known bug. Also look in our code for CREF_ITER, which the new frontend is supposed to use in order to avoid conflicts.
If there is a strong need it can probably also be implemented in the old frontend, but it is a lot of work.

Last edited 11 years ago by Martin Sjölund (previous) (diff)

comment:2 by Lennart Ochel, 11 years ago

There is no strong need to fix this for me. I can easily avoid such conflicts in my models ;-). It is just good to know about this.

comment:3 by Martin Sjölund, 11 years ago

Milestone: 1.9.02.0.0

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

Milestone: 1.9.31.9.4

Moved to new milestone 1.9.4

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

Milestone: 1.9.41.9.5

Milestone pushed to 1.9.5

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

Milestone: 1.9.51.10.0

Milestone renamed

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

Milestone: 1.10.01.11.0

Ticket retargeted after milestone closed

comment:8 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:9 by Francesco Casella, 7 years ago

Owner: changed from Martin Sjölund to Per Östlund
Status: newassigned

@perost, can you please comment on comment:1?

in reply to:  9 comment:10 by Per Östlund, 7 years ago

Replying to casella:

@perost, can you please comment on comment:1?

I don't know how well the rest of the compiler handles this, but the new instantiation knows which crefs refer to iterators. So we can trivially generate CREF_ITER for iterators if necessary.

comment:11 by Francesco Casella, 7 years ago

Milestone: 1.12.0Future

The milestone of this ticket has been reassigned to "Future".

If you think the issue is still valid and relevant for you, please select milestone 1.13.0 for back-end, code generation and run-time issues, or 2.0.0 for front-end issues.

If you are aware that the problem is no longer present, please select the milestone corresponding to the version of OMC you used to check that, and set the status to "worksforme".

In both cases, a short informative comment would be welcome.

comment:12 by Per Östlund, 3 years ago

Milestone: Future1.19.0
Resolution: fixed
Status: assignedclosed

It seems this was fixed at some point, the model now compiles without any issues.

Note: See TracTickets for help on using tickets.