www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/10/02/02:43:44

From: DavMac AT iname DOT com (Davin McCall)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: no copy-ctor for temps
Date: Sat, 02 Oct 1999 04:53:22 GMT
Organization: Monash Uni
Lines: 26
Distribution: world
Message-ID: <37f58ee3.303610@newsserver.cc.monash.edu.au>
References: <37f564ff DOT 3448616 AT newsserver DOT cc DOT monash DOT edu DOT au> <eb8J3.1214$%K6 DOT 36 AT firefly> <7_eJ3.1245$%K6 DOT 53 AT firefly>
NNTP-Posting-Host: damcc5.halls.monash.edu.au
X-Trace: towncrier.cc.monash.edu.au 938839999 18968 130.194.198.138 (2 Oct 1999 04:53:19 GMT)
X-Complaints-To: abuse AT monash DOT edu DOT au
NNTP-Posting-Date: 2 Oct 1999 04:53:19 GMT
X-Newsreader: Forte Free Agent 1.1/32.230
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

On Sat, 02 Oct 1999 03:29:07 GMT, wemccaug AT prairienet DOT org (Wendy E.
McCaughrin) wrote:

> This is a good point -- in fact, I was compiling with -O (but it
> would be nice to be warned of such optimizations). BTW, if -O is
> assuming that default (bit-wise) copy is always more efficient
> than invoking the copy-ctor, doesn't that require some knowledge
> of what the copy-ctor does?

Using -O doesn't make gcc assume that the bitwise copy is more
efficient than invoking the copy-ctor. gcc will *never* do a bitwise
copy if a copy-ctor is defined. The point I am trying to make is, in
the example program you gave, no copy was performed (bitwise, or via
the ctor).

The temporary object is simply constructed (using the char *
conversion ctor) directly on the stack, right where it needs to be in
order for it to be passed to the function.

I hope this is more clear.

Davin.

__________________________________________________________
       *** davmac - sharkin'!! davmac AT iname DOT com ***
my programming page: http://yoyo.cc.monash.edu.au/~davmac/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019