🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c++
Article #797

copies and copy constructors

#797
From: Jim ADCOCK
Date: Thu, 24 Jan 1991 02:20
35 lines
1984 bytes
I'm trying to figure out where copies are "guaranteed" to exist and/or 
not to exist in C++, and I'm getting very confused.  See Dec. JCLT for related
ANSI-C issues.

Part of the problem is that "copy" can be both a noun or verb thing.  
A "copy" can mean an invocation of a copy constructor, it can mean a
separate region of memory, or it can mean both.

The issue is important for "object oriented" - style programming where
polymorphism and identity is important.  Programmers must be able to
"guarantee" in some situations that a copy is/is-not  generated, so that the
tests based on identity will work "correctly."  In this sense, a "copy" means
a distinct region of memory.

Some questions:

When a function returns-by-copy, is the region of memory that copy 
resides in distinct? [bottom of ARM page 288 seems to be implying that
C++ does indeed return-by-copy, but I guess one could even question that]

When, if ever, is it legal to invoke a copy constructor where
the source and destination memory locations are identical?

When, if ever, is it legal to invoke a copy constructor where
the source and destination memory locations are partially overlapping?

When, if ever, is it legal to have partially overlapping references
to the same object?

[please quote your sources when answering these questions]

[note that most of these questions could be applied separately for
 compiler-initiated actions [temporaries] and for programmer initiated
 actions, but I'm assuming that which a compiler is allowed to do,
 the programmer is allowed to do, and vice-versa]
Technical Details
Message-ID: <70198@microsoft.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!lll-winken!uunet!microsoft!jimad

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!lll-winken!uunet!microsoft!jimad
From: jimad@microsoft.UUCP (Jim ADCOCK)
Newsgroups: comp.std.c++
Subject: copies and copy constructors
Message-ID: <70198@microsoft.UUCP>
Date: 24 Jan 91 02:20:18 GMT
Reply-To: jimad@microsoft.UUCP (Jim ADCOCK)
Organization: Microsoft Corp., Redmond WA
Lines: 35