OMNeT++/OMNEST Bug Tracker - OMNeT++
View Issue Details
0000793OMNeT++simulation kernelpublic2014-11-28 13:222014-11-30 07:29
andras 
andras 
normalminoralways
resolvedfixed 
4.5 
4.6 
0000793: NED: local parameters cannot be used to initialize an inherited parameter
In NED, local parameters cannot be used to initialize an inherited parameter. Moreover, the result will be incorrect (0) instead of an error message.

This can be best demonstrated on channels. See the following code:

channel C extends ned.DatarateChannel {
    double foo @unit(Gbps);
    datarate = foo;
}

omnetpp.ini:
[General]
network = <a network that contains channels of type C>
**.foo = 42

The result will be datarate=0.

The same effect can be reproduced with module inheritance.
No tags attached.
Issue History
2014-11-28 13:22andrasNew Issue
2014-11-28 13:24andrasNote Added: 0000951
2014-11-28 13:33andrasNote Added: 0000952
2014-11-28 13:34andrasNote Edited: 0000951bug_revision_view_page.php?bugnote_id=951#r4
2014-11-30 07:29andrasNote Added: 0000954
2014-11-30 07:29andrasStatusnew => resolved
2014-11-30 07:29andrasFixed in Version => 4.6
2014-11-30 07:29andrasResolutionopen => fixed
2014-11-30 07:29andrasAssigned To => andras
2015-10-12 09:28ammmar1988Issue cloned: 0000875

Notes
(0000951)
andras   
2014-11-28 13:24   
(edited on: 2014-11-28 13:34)
Full code for reproducing the bug:

channel C extends ned.DatarateChannel {
    int foo @unit(Gbps);
    datarate = foo;
}

module Node {
  gates:
    inout g;
  connections allowunconnected:
}

network Net {
  submodules:
    a: Node;
    b: Node;
  connections:
    a.g <--> C <--> b.g;
}


omnetpp.ini:
[General]
network = Net
**.foo = 42

(0000952)
andras   
2014-11-28 13:33   
Problem is twofold:

(1) parameters are initialized in the order of declaration, basetype-to-subtype, and top-down (within a type) order. Then, datarate=x should cause a "parameter x not yet initialized" error. This doesn't happen due to another issue:

(2) during in the parameter initialization stage, it is not checked that a referenced variable has indeed been already initialized. Therefore the construction-time value of x (zero) is used for datarate. (Note that this can no longer happen when module initialize() is called, as all parameters are guaranteed to be initialized by that time.)

Issue (2) can be easily fixed. (1) is more difficult, as the parameter initialization strategy itself has to be modified to be more flexible.
(0000954)
andras   
2014-11-30 07:29   
Fixed. Parameters of the same module/channel can freely cross-reference each other, as long as they are no cycles. Cycles are reported as errors.