Opened 11 years ago

Last modified 3 years ago

#2292 assigned defect

wrong generated C code

Reported by: Adeel Asghar Owned by: Lennart Ochel
Priority: high Milestone:
Component: Backend Version: trunk
Keywords: Cc: bouzakariaahmed@…, Lennart Ochel

Description

The compiler generate the wrong code for the following the algorithm,

temper[i]:=17 + temper[i];

The following C code is generated,

real_array_create(&tmp0, ((modelica_real*)&($Ptemper)), 1, 10);
      (*real_array_element_addr(&$Ptemper, 1, (modelica_integer)$Pi)) = (17.0 + (*real_array_element_addr(&tmp0, 1, (modelica_integer)$Pi)));

I believe it should be,

real_array_create(&tmp0, ((modelica_real*)&($Ptemper)), 1, 10);
      (*real_array_element_addr(&tmp0, 1, (modelica_integer)$Pi)) = (17.0 + (*real_array_element_addr(&tmp0, 1, (modelica_integer)$Pi)));

On the left hand side we should use &tmp0 instead of &$Ptemper.

The simulation executable segfaults.

The complete model is attached.

Attachments (1)

Sample_Vs_vector.mo (378 bytes ) - added by Adeel Asghar 11 years ago.

Download all attachments as: .zip

Change History (18)

by Adeel Asghar, 11 years ago

Attachment: Sample_Vs_vector.mo added

comment:1 by Lennart Ochel, 11 years ago

Cc: Lennart Ochel added

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

Milestone: 1.9.01.9.1

Postponed until 1.9.1

comment:3 by Willi Braun, 10 years ago

Component: Code GenerationBackend
Owner: changed from Willi Braun to Lennart Ochel
Status: newassigned

This ones also works in the meanwhile, although only with numerical initialization.

"Notification: The given system is mixed-determined.   [index > 0]
Notification: The given system is mixed-determined.   [index > 1]
Notification: The given system is mixed-determined.   [index > 2]
Notification: The given system is mixed-determined.   [index > 3]
Warning: No system for the symbolic initialization was generated. A method using numerical algorithms will be used instead.
"
Last edited 10 years ago by Willi Braun (previous) (diff)

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

Milestone: 1.9.11.9.2

This ticket was not closed for 1.9.1, which has now been released. It was batch modified for milestone 1.9.2 (but maybe an empty milestone was more appropriate; feel free to change it).

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

Milestone: 1.9.21.9.3

Milestone changed to 1.9.3 since 1.9.2 was released.

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

Milestone: 1.9.31.9.4

Moved to new milestone 1.9.4

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

Milestone: 1.9.41.9.5

Milestone pushed to 1.9.5

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

Milestone: 1.9.51.10.0

Milestone renamed

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

Milestone: 1.10.01.11.0

Ticket retargeted after milestone closed

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

Milestone: 1.12.01.13.0

As of v1.13.0-dev-188-g2c5818d, the simulation no longer segfaults, but the generated code is still not correct: the temper array is not updated as expected and there singular linear systems generated that should not be there.

comment:12 by Francesco Casella, 6 years ago

Still the same problem as of 1.13.0 final.

comment:13 by Francesco Casella, 6 years ago

Milestone: 1.13.01.14.0

Rescheduled to 1.14.0 after 1.13.0 releasee

comment:14 by Francesco Casella, 5 years ago

Milestone: 1.14.01.16.0

Releasing 1.14.0 which is stable and has many improvements w.r.t. 1.13.2. This issue is rescheduled to 1.16.0

comment:15 by Francesco Casella, 4 years ago

Milestone: 1.16.01.17.0

Retargeted to 1.17.0 after 1.16.0 release

comment:16 by Francesco Casella, 4 years ago

Milestone: 1.17.01.18.0

Retargeted to 1.18.0 because of 1.17.0 timed release.

comment:17 by Francesco Casella, 3 years ago

Milestone: 1.18.0

Ticket retargeted after milestone closed

Note: See TracTickets for help on using tickets.