Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!att!dptg!pegasus!psrc From: psrc@pegasus.ATT.COM (Paul S. R. Chisholm) Newsgroups: comp.lang.c++ Subject: Re: Change to delete is in order Summary: it's in there already! Message-ID: <4538@pegasus.ATT.COM> Date: 19 Mar 90 04:16:11 GMT References: <5136@odin.SGI.COM> <25FC0210.26173@paris.ics.uci.edu> <260349F1.24972@paris.ics.uci.edu> Organization: AT&T Bell Laboratories Lines: 38 In article <5263@odin.SGI.COM> shap@delrey.sgi.com (Jonathan Shapiro) suggests that "delete p" should set the value of p to a null pointer after the memory it points at is free. Later posters suggest that the pointer may not be an lvalue. I haven't seen anyone suggest a decent example where a non-lvalue *should* be passed to delete, and I have a strong gut feeling that such an expression should probably generate a warning! But anyway, if it's an lvalue, yes, I agree, implementors should be free to zero out the pointer. (Or not, if the application is *so* time critical that the assignment might slow things down. We all know how expensive assignment is as compared to memory deallocation, right?-) Leaving the value alone may also help debugging. In article <260349F1.24972@paris.ics.uci.edu>, rfg@ics.uci.edu (Ronald Guilmette) agrees, writing: > It would certainly be nice if the language definition were to say that: > "In cases where the expression given in a delete statement is an lvalue, > the value of that lvalue after the execution of the delete statement is > undefined." Well, open your ugly red book ("UNIX(R) System V AT&T C++ Language System, Release 2.0, Product Reference Manual", select code 307-146) to page 20, and repeat after me: "if the expression denoting the object in a delete expression is a modifiable lvalue its value is undefined after the deletion." Well, it's good to know Dr. Stroustrup agrees with us. . . .-) > // Ron Guilmette (rfg@ics.uci.edu) Paul S. R. Chisholm, AT&T Bell Laboratories att!pegasus!psrc, psrc@pegasus.att.com, AT&T Mail !psrchisholm I'm not speaking for the company, I'm just speaking my mind. UNIX(R) is a registered trademark of AT&T. P.S.: How does one have an unmodifiable lvalue? By using the const keyword, of course. I'd like a warning there, too.