Opened 11 years ago

Closed 3 years ago

#2214 closed defect (fixed)

code generation for iteration variable

Reported by: lochel Owned by: perost
Priority: high Milestone: 1.19.0
Component: Code Generation Version: trunk
Keywords: Cc: lochel, wbraun

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 Changed 11 years ago by sjoelund.se

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 runtime, but it is a lot of work.

Version 0, edited 11 years ago by sjoelund.se (next)

comment:2 Changed 11 years ago by lochel

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 Changed 11 years ago by sjoelund.se

  • Milestone changed from 1.9.0 to 2.0.0

comment:4 Changed 9 years ago by sjoelund.se

  • Milestone changed from 1.9.3 to 1.9.4

Moved to new milestone 1.9.4

comment:5 Changed 9 years ago by sjoelund.se

  • Milestone changed from 1.9.4 to 1.9.5

Milestone pushed to 1.9.5

comment:6 Changed 9 years ago by sjoelund.se

  • Milestone changed from 1.9.5 to 1.10.0

Milestone renamed

comment:7 Changed 8 years ago by sjoelund.se

  • Milestone changed from 1.10.0 to 1.11.0

Ticket retargeted after milestone closed

comment:8 Changed 8 years ago by sjoelund.se

  • Milestone changed from 1.11.0 to 1.12.0

Milestone moved to 1.12.0 due to 1.11.0 already being released.

comment:9 follow-up: Changed 7 years ago by casella

  • Owner changed from sjoelund.se to perost
  • Status changed from new to assigned

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

comment:10 in reply to: ↑ 9 Changed 7 years ago by perost

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

  • Milestone changed from 1.12.0 to Future

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 Changed 3 years ago by perost

  • Milestone changed from Future to 1.19.0
  • Resolution set to fixed
  • Status changed from assigned to closed

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

Note: See TracTickets for help on using tickets.