Opened 13 years ago

Closed 7 years ago

#1680 closed defect (fixed)

Error in generated C code for arrays with undetermined size

Reported by: chenouard-r Owned by: chenouard-r
Priority: high Milestone:
Component: Code Generation Version:
Keywords: Cc: chenouard-r

Description (last modified by Martin Sjölund)

I build a "simple" example with a model and a function based on an array of an undetermined size. I think I conformed to Modelica language, but some other Modelica compilers also don't achieve in executing this code (mainly a problem with my use of sum function). The modelica code and 2 of the main C files generated by OpenModelica are joined as attached files. I use OpenModelica Compiler 1.8.0 (r10946).

I got the following errors when compiling:

Test.Test1.c: In function ‘eqFunction_3’:
Test.Test1.c:279: error: expected expression before ‘:’ token
Test.Test1.c:289: error: ‘$P$reductionFoldTmpA’ undeclared (first use in this function)
Test.Test1.c:289: error: (Each undeclared identifier is reported only once
Test.Test1.c:289: error: for each function it appears in.)
Test.Test1.c:289: error: ‘$P$reductionFoldTmpB’ undeclared (first use in this function)
Test.Test1.c: In function ‘eqFunction_6’:
Test.Test1.c:385: error: expected expression before ‘:’ token
Test.Test1.c:395: error: ‘$P$reductionFoldTmpA’ undeclared (first use in this function)
Test.Test1.c:395: error: ‘$P$reductionFoldTmpB’ undeclared (first use in this function)

I suppose there is a problem when reformulating and generating the C code. The ':' symbol is used to state C arrays and some temporary variables are not define before use.

Attachments (3)

Test.Test1.c (13.4 KB ) - added by chenouard-r 13 years ago.
test.mo (799 bytes ) - added by chenouard-r 13 years ago.
_Test.Test1.h (5.9 KB ) - added by chenouard-r 13 years ago.

Download all attachments as: .zip

Change History (6)

by chenouard-r, 13 years ago

Attachment: test.mo added

by chenouard-r, 13 years ago

Attachment: _Test.Test1.h added

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

This is somewhat hard to fix easily. I added a better error-message though. Implementation note: Either fix the cref to have type ARRAY(... DIM_EXP(n-1)) or fix codegen to take both dimension and expression to backpatch dimensions. I like the former better than the latter.

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

Cc: chenouard-r, → chenouard-r
Component: Backend
Description: modified (diff)

comment:3 by Dietmar Winkler, 9 years ago

Milestone: Future

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

Component: BackendCode Generation
Milestone: Future
Resolution: fixed
Status: newclosed

This was fixed at some point.

Note: See TracTickets for help on using tickets.