[sv-ec] [SystemVerilog Errata 00000025] Pass by reference behavior of dynamically allocated objects

From: Neil Korpusik <Neil.Korpusik@Sun.com>
Date: Mon Sep 13 2004 - 16:38:25 PDT

It looks like there is some confusion as to how pass by reference works.
The description of the pass by reference behavior that Dave is requesting to
be added doesn't match my understanding of how pass by reference actually
works.

> Summary: Pass by reference behavior of dynamically allocated objects
> Description:
> Section 10.4.2 needs to document how pass by works with dynamically
> allocated objects, especially when the dynamic object is modified from
> outside the scope of the calling task or function.

I assume you are referring to pass by reference as stated in the summary
even though here you just say "pass by".

> If an explicit or implicit 'new' operation occurs after the task/function
> call, the reference should still point to the old data, which is no longer
> visible outside the scope of the call. Same functionality for passing an
> element of an associative array.

new() is used with more than one construct.

objects - a call to new() will cause the object handle to refer to a new
           instance of the object. Both the calling scope and the called
           task will both immediately be referring to the new instance right
           after the call to new(). The original instance of the object will
           be garbage collected unless there is another handle which is still
           referring to it.

dynamic array - a call to new[] can be used to change the size of the array.
           The old data will or will not be retained depending upon whether
           initial values are specified on the call to new[]. In this case
           both scopes continue to refer to the same array. Changes to the
           size and/or contents of the array will be visible to both scopes.

> For strings and queues, an algorithm needs to be defined to preserve
> references when they are modified.

I am not sure what you are getting at here. The contents of a string or
queue can be modified by either scope and those changes will then be
visible in both scopes. The semantics of pass by reference for these
constructs is no different than the pass by reference semantics for an
integer.

Neil

-------- Original Message --------
Subject: [SystemVerilog Errata 0000025]: Pass by reference behavior of dynamically allocated objects
Date: Tue, 31 Aug 2004 10:39:44 -0700 (PDT)
From: sv@eda.org

The following bug has been ASSIGNED.
======================================================================
http://www.eda.org/svdb/bug_view_page.php?bug_id=0000025
======================================================================
Reported By: daver
Assigned To: neil
======================================================================
Project: SystemVerilog Errata
Bug ID: 25
Category: SV-EC
Reproducibility: always
Severity: minor
Priority: immediate
Status: assigned
Type: Clarification
======================================================================
Date Submitted: 07-02-2004 15:48 BST
Last Modified: 08-31-2004 10:39 BST
======================================================================
Summary: Pass by reference behavior of dynamically allocated objects
Description:
Section 10.4.2 needs to document how pass by works with dynamically
allocated objects, especially when the dynamic object is modified from
outside the scope of the calling task or function.

If an explicit or implicit 'new' operation occurs after the task/function
call, the reference should still point to the old data, which is no longer
visible outside the scope of the call. Same functionality for passing an
element of an associative array.

For strings and queues, an algorithm needs to be defined to preserve
references when they are modified.

======================================================================

Bug History
Date Modified Username Field Change
======================================================================
07-02-04 15:48 daver New Bug
07-02-04 15:48 daver Type => Clarification
08-06-04 11:12 pieper Description Updated
08-06-04 11:12 pieper Priority normal => immediate
08-31-04 10:39 bpierce Assigned To => neil
08-31-04 10:39 bpierce Status new => assigned
======================================================================

-- 
---------------------------------------------------------------------
Neil Korpusik                                     Tel: 408-720-4852
Member of Technical Staff                         Fax: 408-720-4850
Frontend Technologies - ASICs & Processors (FTAP)
Sun Microsystems
email: neil.korpusik@sun.com
---------------------------------------------------------------------
Received on Mon Sep 13 16:37:49 2004

This archive was generated by hypermail 2.1.8 : Mon Sep 13 2004 - 16:38:22 PDT