Section 8.12 of the LRM is not clear to me on what happens when a shallow copy is made of an object of a type that has arrays.
E.g.
class X;
int a[];
endclass
X x1,x2;
x1=new();
x1.a='{1,2,3,4,5};
x2=new x1;
Will x2’s a array have the values 1,2,3,4,5 ?
In reply to Nico75:
module kyd();
class X;
int a;
endclass
X x1,x2;
initial
begin
x1=new();
x1.a='{1,2,3,4,5};
x2=new x1;
$display("value of x2=%p",x2.a);
#100 $finish;
end
endmodule
output: value of x2='{1, 2, 3, 4, 5}
In reply to Nico75:
I do not see what is not clear in the LRM. It says “All of the variables are copied”. There are no exceptions. An array is a variable, so it gets copied.
The rest of the text is just pointing out what has already been described when copying a class variable — you are copying the value of the handle, not the object the handle references.