home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / gnu / g / bug / 2351 < prev    next >
Encoding:
Internet Message Format  |  1993-01-28  |  1.9 KB

  1. 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
  2. From: jbuck@forney.berkeley.edu (Joe Buck)
  3. Newsgroups: gnu.g++.bug
  4. Subject: Re: 2.3.3: premature dtor of temp?
  5. Date: 26 Jan 1993 22:14:44 -0500
  6. Organization: U. C. Berkeley
  7. Lines: 31
  8. Sender: daemon@cis.ohio-state.edu
  9. Approved: bug-g++@prep.ai.mit.edu
  10. Distribution: gnu
  11. Message-ID: <1k41kg$nkf@agate.berkeley.edu>
  12. References: <9301242117.AA04053@cs.rice.edu>
  13. Summary: it's legal (for now)
  14.  
  15. In article <9301242117.AA04053@cs.rice.edu> dougm@cs.rice.edu (Doug Moore) writes:
  16. >The program that follows demonstrates (I think) that under some
  17. >circumstances, g++ destroys a temporary prematurely.  The ARM is a bit
  18. >too vague to let me say with complete confidence that this is a bug,
  19. >but it certainly ought to be.
  20.  
  21. The g++ behavior (early destruction of temporaries) is legal according to
  22. the ARM.  This is partly because the ARM is so permissive on this subject.
  23. See the gnu.g++.help FAQ; also, you might take a look at recent discussion
  24. on comp.std.c++ about what the ANSI C++ committee is doing about the
  25. destruction of temporaries issue (they are still debating it).
  26.  
  27. Sun C++ is a port of cfront, which destroys temporaries very late (at
  28. the end of the containing scope).  If you write a program that depends on
  29. this behavior, you have written a non-portable program, and you'll have
  30. problems on other compilers as well.
  31.  
  32. It appears that eventually ANSI will mandate that temporaries live
  33. longer than they do now, but not (necessarily) as long as they do in
  34. cfront.  When that happens, you can expect the g++ maintainers to
  35. conform.
  36.  
  37. See the FAQ for some suggestions on how to work around problems caused
  38. by this.  Basically, you can give the temporary a name (by using it
  39. to initialize a reference), guaranteeing that it will live until the
  40. end of scope of that name.
  41.  
  42.  
  43. --
  44. Joe Buck    jbuck@ohm.berkeley.edu
  45.  
  46.