Array in "randomize with" constraint is not properly incrementing its index

In reply to Reuben:

I have a question in the following code that

module randomize;
 
bit [14:0] addr_arr[3] = {15'h7ffc, 15'h7ff2, 15'h7ffb};
int msg_id = 0;
packet pkt;
 
initial begin
    pkt = new();
 
    repeat(3) begin
      $display ("msg_id is: %0d, addr_arr[msg_id] is %0h", msg_id, addr_arr[msg_id]);
      pkt.randomize() with {addr == addr_arr[msg_id];};
      $display ("pkt address choosen is: %0h", pkt.addr);
      msg_id++;
    end
end

Mighty be this is bug as in the repeat 3 the pkt is not created object for 3 times so it might have the object 
So i think there the code should be like this 
initial begin
   
    repeat(3) begin
      pkt = new();
      $display ("msg_id is: %0d, addr_arr[msg_id] is %0h", msg_id, addr_arr[msg_id]);
           pkt.randomize() with {addr == addr_arr[msg_id];};
      $display ("pkt address choosen is: %0h", pkt.addr);
      msg_id++;
    end
end

Thanks
Aditya