In reply to robert.liu:
I don’t think this is or should be legal. A dynamic array is SystemVerilog-only datatype and memory management occurs on the SystemVerilog side. If the size of the dynamic array gets changed, the location of the memory might get changed as well. Even if the size does not change the memory manager is free to move the array around to make room for other arrays that grow or shrink.
If the dynamic array is a C compatible type, the array is going to be passed by reference anyways. If there are no changes to the array between steps 1 & 3, it will probably just pass the same reference pointer again, so there would be no performance penalty.