home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!elroy.jpl.nasa.gov!sdd.hp.com!think.com!barmar
- From: barmar@think.com (Barry Margolin)
- Newsgroups: comp.lang.c++
- Subject: Re: Proposal: auto T&
- Date: 21 Aug 1992 03:00:40 GMT
- Organization: Thinking Machines Corporation, Cambridge MA, USA
- Lines: 39
- Message-ID: <171m8oINNdu7@early-bird.think.com>
- References: <1992Aug20.171342.3589@sunb10.cs.uiuc.edu> <9223406.29682@mulga.cs.mu.OZ.AU> <1992Aug20.213417.5690@sunb10.cs.uiuc.edu>
- NNTP-Posting-Host: gandalf.think.com
-
- In article <1992Aug20.213417.5690@sunb10.cs.uiuc.edu> pjl@sparc10.cs.uiuc.edu (Paul Lucas) writes:
- >In <9223406.29682@mulga.cs.mu.OZ.AU> fjh@munta.cs.mu.OZ.AU (Fergus James HENDERSON) writes:
- >>What do you mean by "it's not reentrant"? Why not?
- >
- >*****> Because the "slot" allocated in the caller would first receive
- > the temporary generated by "stringfunction( b )" then it would
- > be clobbered by "stringfunction( c )"
-
- I think the rest of us understood that enough temporaries would be
- allocated so that there would be no clobbering.
-
- > The problem with that is, what does the compiler do if a
- > function returning an auto& calls itself?
-
- That's what stack frames are for. Each stack frame for the function would
- contain space for all the temporaries that are returned.
-
- The easiest way to understand this is to transform the program into a
- version where the temporaries are explicit. Thus,
-
- String a, b, c; // also assume + has been overloaded
- // ...
- a = stringfunction( b ) + stringfunction( c );
-
- is equivalent to:
-
- String a, b, c, temp1, temp2;
- // ...
- temp1 = stringfunction(b);
- temp2 = stringfunction(c);
- a = temp1 + temp2;
-
- Your claim of non-reentrancy suggests that you think the temporaries would
- be static, not automatic.
- --
- Barry Margolin
- System Manager, Thinking Machines Corp.
-
- barmar@think.com {uunet,harvard}!think!barmar
-