Erling Posted December 4, 2011 Report Share Posted December 4, 2011 I have a problem with virtual functions being treated as if they were non-virtual in a parameterized class. Consider: class MyComp #(type T) extends uvm_subscriber #(T); function new(); super.new("", null); endfunction function void f(); $display("%s", get_type_name()); endfunction function void write(T t); endfunction function string get_type_name(); return "MyComp#(T)"; endfunction endclass class MyOtherComp extends MyComp #(int); function string get_type_name(); return "MyOtherComp"; endfunction endclass initial begin MyOtherComp c = new(); c.f(); end I had hoped this would print "MyOtherComp" since get_type_name() is virtual in uvm_object, but what's printed is "MyComp#(T)". Is this a bug or am I missing something obvious? The compiler is Questa 10.0d. Erling Quote Link to comment Share on other sites More sharing options...
uwes Posted December 5, 2011 Report Share Posted December 5, 2011 hi, IUS prints "MyOtherComp" - as far as i see thats the correct value /mfg Quote Link to comment Share on other sites More sharing options...
dave_59 Posted December 5, 2011 Report Share Posted December 5, 2011 Hi Erling, This is a reported bug in Questa. It has to do with the interaction of a variety of things and you can contact Mentor for more details. The quick workaround is prefix the call with 'this.' or add the virtual keyword in all derived methods. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.