-
Notifications
You must be signed in to change notification settings - Fork 182
Open
Labels
Description
When a class member is initialized both inline and in the constructor, the LRM seems vague about the order those initializations occur in. With VCS we are seeing that the constructor code is executed first, and then the inline-initializer is applied last, overriding the constructor initialization. I haven't been able to find explicit LRM language for the correct behavior here yet.
What would be the complexity of implementing a warning that triggers if a class-member is written to by both an inline-initialization as well as from the constructor, or any function called by the constructor (and if those functions are virtual, then by any extended class implementations of the virtual-function)?
Running sandbox test.
B::init() begin my_int = 0
B::init() end my_int = 2
B::new() end my_int = 1
Finished sandbox test.
class A;
function new();
init();
endfunction
virtual function void init();
endfunction
endclass
class B extends A;
int unsigned my_int = 1;
function new();
super.new();
$display("B::new() end my_int = %0d", my_int);
endfunction
virtual function void init();
$display("B::init() begin my_int = %0d", my_int);
super.init();
my_int = 2;
$display("B::init() end my_int = %0d", my_int);
endfunction
endclass
module test;
B b;
initial begin
$display("Running sandbox test.");
b = new();
$display("Finished sandbox test.");
end
endmodule