#2720 closed defect (fixed)
Ordering of ExternalObject constructors is reversed
| Reported by: | Owned by: | Per Östlund | |
|---|---|---|---|
| Priority: | high | Milestone: | 1.9.1 |
| Component: | Code Generation | Version: | trunk |
| Keywords: | ExternalObject constructor order | Cc: |
Description
This is a simple example that tries to instantiate two ExternalObject clasees, passing one object as a parameter to the other.
Running this simple example with omc nightly builds results in the following error:
Bar ctor called (param=(nil)) Test: ./ExtObj.h:28: void *barCtor(void *): Assertion `param==(void*)0x11111111' failed. Aborted (core dumped)
It looks like the order in which constructors are called is reversed. A look at the C sources generated by omc resulted in this (Test_01exo.c):
/* Has to be performed after _init.xml file has been read */
void Test_callExternalObjectConstructors(DATA *data)
{
/* data->simulationInfo.extObjs = NULL; */
infoStreamPrint(LOG_DEBUG, 0, "call external Object Constructors");
$Pbar = omc_P_Bar_constructor(threadData, $Pfoo);
$Pfoo = omc_P_Foo_constructor(threadData);
infoStreamPrint(LOG_DEBUG, 0, "call external Object Constructors finished");
}
So the constructors are called in reverse order.
Note: the following was built using
omc +s ExtObj.mo make -f Test.makefile ./Test
Attachments (1)
Change History (4)
by , 11 years ago
| Attachment: | ExtObj.zip added |
|---|
comment:1 by , 11 years ago
| Owner: | changed from to |
|---|---|
| Status: | new → accepted |
comment:2 by , 11 years ago
| Resolution: | → fixed |
|---|---|
| Status: | accepted → closed |
Fixed in r21020, the list of external objects was indeed mistakenly reversed. I also added your example as a test case in our test suite.

Simplified example that triggers the bug