In reply to srividya2u:
I think this is tool implementation specific. I tired to run the same code on VCS and it gave error:
Error-[NOA] Null object access
oops1.sv, 17
The object is being used before it was constructed/allocated.
Please make sure that the object is newed before using it.
#0 in \class_B::new_compare at oops1.sv:17
#1 in unnamed$$_1 at oops1.sv:26
#2 in top