| Login | | Don't have an account yet? You can create one. As a registered user you have some advantages like theme manager, comments configuration and post comments with your name. | |
| Who's Online | There are currently, 55 guest(s) and 1 member(s) that are online.
You are Anonymous user. You can register for free by clicking here | |
 | |
|
Verification Guild: Forums |
|
| View previous topic :: View next topic |
| Author |
Message |
dave_59 Senior


Joined: Jun 22, 2004 Posts: 974 Location: Fremont, CA
|
Posted: Wed Jan 04, 2012 12:41 pm Post subject: |
|
|
nimesh,
Calling a virtual method from a constructor is a dangerous thing to do. Initialization of class members starts at the base class and moves down the extended hierarchy. But if the initialization of a base class member calls a virtual method, the extended class members have not been initialized yet. See http://www.eda.org/svdb/view.php?id=2488
They should be illegal, but I think it would be difficult for a compiler to check if there are nested method calls except at run time, which would be very expensive.
Using the OVM/UVM, there is very little you put in the constructor. A separate build() method is used to perform most of the actual construction and avoids this problem. |
|
| Back to top |
|
 |
nimesh Newbie


Joined: Jan 03, 2012 Posts: 2
|
Posted: Thu Jan 05, 2012 12:29 am Post subject: |
|
|
Hi Dave,
I really appreciate your response.
I also had the same understanding but whole upper thread of Mr. Amer Sultan and BugCatcher points to unexpected output of calling virtual method from constructor. That confused me about execution flow. I put the simulation result here for clarification of calling virtual methods from constructor. It will call its own method not the derived class. This will help other user to understand flow better J!.
Regards,
-Nimesh |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
| |
|
|