home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!stanford.edu!agate!ames!saimiri.primate.wisc.edu!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!cis.ohio-state.edu!forney.berkeley.edu!jbuck
- From: jbuck@forney.berkeley.edu (Joe Buck)
- Newsgroups: gnu.g++.bug
- Subject: Re: 2.3.3: premature dtor of temp?
- Date: 26 Jan 1993 22:14:44 -0500
- Organization: U. C. Berkeley
- Lines: 31
- Sender: daemon@cis.ohio-state.edu
- Approved: bug-g++@prep.ai.mit.edu
- Distribution: gnu
- Message-ID: <1k41kg$nkf@agate.berkeley.edu>
- References: <9301242117.AA04053@cs.rice.edu>
- Summary: it's legal (for now)
-
- In article <9301242117.AA04053@cs.rice.edu> dougm@cs.rice.edu (Doug Moore) writes:
- >The program that follows demonstrates (I think) that under some
- >circumstances, g++ destroys a temporary prematurely. The ARM is a bit
- >too vague to let me say with complete confidence that this is a bug,
- >but it certainly ought to be.
-
- The g++ behavior (early destruction of temporaries) is legal according to
- the ARM. This is partly because the ARM is so permissive on this subject.
- See the gnu.g++.help FAQ; also, you might take a look at recent discussion
- on comp.std.c++ about what the ANSI C++ committee is doing about the
- destruction of temporaries issue (they are still debating it).
-
- Sun C++ is a port of cfront, which destroys temporaries very late (at
- the end of the containing scope). If you write a program that depends on
- this behavior, you have written a non-portable program, and you'll have
- problems on other compilers as well.
-
- It appears that eventually ANSI will mandate that temporaries live
- longer than they do now, but not (necessarily) as long as they do in
- cfront. When that happens, you can expect the g++ maintainers to
- conform.
-
- See the FAQ for some suggestions on how to work around problems caused
- by this. Basically, you can give the temporary a name (by using it
- to initialize a reference), guaranteeing that it will live until the
- end of scope of that name.
-
-
- --
- Joe Buck jbuck@ohm.berkeley.edu
-
-