RE: [sv-ec] A question about copy constructors

From: Rich, Dave <Dave_Rich_at_.....>
Date: Fri Jan 19 2007 - 11:38:03 PST
As far as "correctness" is concerned, the current LRM has no
restrictions on what the handle on the RHS of the constructor could be
pointing to, other than in must be assignment compatible to the handle
on the LHS. Null certainly fits within these rules, and the LRM mentions
no need to generate an error. 

So to require an error would not be backwards compatible with the
current LRM.

But I suspect people are more interested in what the *desirable*
behavior should be. If we take an analogy from C, malloc(0) returns a
null pointer and is not an exception case. I don't believe that this
will be a problem for debug as most people want to do a deep copy, and
the shallow copy will be at the root of that deep copy, if at all.

Dave


> -----Original Message-----
> From: owner-sv-ec@server.eda.org [mailto:owner-sv-ec@server.eda.org]
On
> Behalf Of Arturo Salz
> Sent: Friday, January 19, 2007 10:45 AM
> To: Rich, Dave; Steven Sharp; paulsen@cadence.com; sv-ec@server.eda-
> stds.org; Arturo.Salz@synopsys.com
> Subject: RE: [sv-ec] A question about copy constructors
> 
> I'm sorry but Steve is correct. The new method is called the
constructor
> precisely because it creates (i.e., allocates) the object. When
someone
> writes code such as:
> 
> 	p = new q;
> 
> After executing that statement, the expectation is that p will contain
a
> handle to an object that has been created. The term new implies that a
> *newly created* object has been initialized. If the source handle is
> null, you cannot create an object copy so the only reasonable thing is
> to issue an error. As I said before, relaxing the implementation only
> leads to additional debug by users. If having a null object is OK then
> that check should be done by the user prior to calling the copy
> constructor.
> 
> 	Arturo
> 
> -----Original Message-----
> From: Rich, Dave [mailto:Dave_Rich@mentor.com]
> Sent: Thursday, January 18, 2007 5:23 PM
> To: Steven Sharp; paulsen@cadence.com; sv-ec@eda-stds.org;
> Arturo.Salz@synopsys.COM
> Subject: RE: [sv-ec] A question about copy constructors
> 
> A copy of nothing is nothing...
> 
> 'nothing' IS created.
> 
> 
> Nothing from Nothing leaves Nothing....
> http://billypreston.lyrics.info/nothingfromnothing.html
> 
> 
> > -----Original Message-----
> > From: Steven Sharp [mailto:sharp@cadence.com]
> > Sent: Thursday, January 18, 2007 4:21 PM
> > To: sharp@cadence.com; paulsen@cadence.com; sv-ec@eda-stds.org;
> > Arturo.Salz@synopsys.com; Rich, Dave
> > Subject: RE: [sv-ec] A question about copy constructors
> >
> >
> > >But you are making a copy of what the handle points to: nothing.
> >
> > But 'new' creates an object.  If you do not create an object, then
> > you have not performed the primary function of 'new'.  If you do
> > create an object, then that object is not a copy of what the other
> > handle points to.
> >
> > Steven Sharp
> > sharp@cadence.com
> 
> 
> --
> This message has been scanned for viruses and
> dangerous content by MailScanner, and is
> believed to be clean.
> 


-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
Received on Fri Jan 19 11:38:28 2007

This archive was generated by hypermail 2.1.8 : Fri Jan 19 2007 - 11:38:42 PST