From 8619000474279279952
X-Google-Thread: f78e5,174aa7b34b06a51
X-Google-Attributes: gidf78e5,public
X-Google-Language: ENGLISH,ASCII-7-bit
Path: g2news1.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local01.nntp.dca.giganews.com!nntp.speakeasy.net!news.speakeasy.net.POSTED!not-for-mail
NNTP-Posting-Date: Fri, 16 Dec 2005 00:00:02 -0600
Return-Path: <devnull@stump.algebra.com>
X-Authentication-Warning: mulga.cs.mu.OZ.AU: fjh set sender to devnull@stump.algebra.com using -f
X-Robomod: STUMP, ichudov@algebra.com (Igor Chudov)
Delivered-To: std-c++@ucar.edu
X-TN-Interface: 209.99.127.20
X-Authentication-Warning: serv4.gc.dca.giganews.com: news set sender to poster@giganews.com using -f
From: David Abrahams <dave@boost-consulting.com>
Subject: Re: Is this really unspecified behavior?
References: <1132759176.368850.264850@g43g2000cwa.googlegroups.com>
	<H1phf.161529$zb5.99785@bgtnsc04-news.ops.worldnet.att.net>
	<1132933832.802917.153350@g14g2000cwa.googlegroups.com>
	<1133551647.532929.325730@z14g2000cwz.googlegroups.com>
	<1133583412.951239.208510@g49g2000cwa.googlegroups.com>
	<E1EjGBD-0005T8-00@chx400.switch.ch>
	<1133910546.716987.80030@g14g2000cwa.googlegroups.com>
	<E1EjzL6-0006ic-00@chx400.switch.ch>
	<0l5ep1ppfhdj5p1pcu7e4na4ub0vjajlq3@4ax.com>
	<200512131507.jBDF72uC006630@horus.isnic.is>
	<uhd9cdgjq.fsf@boost-consulting.com> <E1EmX4R-0006gj-00@chx400.switch.ch>
	<ur78f6zcp.fsf@boost-consulting.com> <Up3of.4761$Kk7.1338@trndny05>
Message-ID: <u64pq5euv.fsf@boost-consulting.com>
User-Agent: Gnus/5.110004 (No Gnus v0.4) Emacs/22.0.50 (windows-nt)
Cancel-Lock: sha1:/Ie26DGF0Og6U8rukVhOLZwjVNw=
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
X-Complaints-To: abuse@rcn.net
X-DMCA-Complaints-To: abuse@rcn.net
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.32
Newsgroups: comp.std.c++
X-Virus-Scanned: amavisd-new at ucar.edu
X-Virus-Scanned: amavisd-new at cs.mu.OZ.AU
Approved: Fergus Henderson <fjh@cs.mu.oz.au>, moderator of comp.std.c++
X-Virus-Scanned: amavisd-new at cs.mu.OZ.AU
Date: Thu, 15 Dec 2005 23:58:24 CST
Lines: 50
NNTP-Posting-Host: 65.182.171.162
X-Trace: sv3-gzaKTv2qOQc/tzhLhzH/5naTZpQY1lMDFTRhNzp7LL5B6qCzN55ASn3cZlBPKz2o3RWwXP5FdMDR8CI!VWK4yTQ1uLNLPohDSFPpHax1IgQ79U9z9P1ft5gyeIBJ43z5JXRPHoSEtG1boZ4zQvH3k4OeFiqo!vty8NfL5egrpYNBlcw==
X-Complaints-To: abuse@speakeasy.net
X-DMCA-Complaints-To: abuse@speakeasy.net
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.32
Xref: g2news1.google.com comp.std.c++:2778

hyrosen@mail.com (Hyman Rosen) writes:

> David Abrahams wrote:
>> f doesn't have an auto_ptr<T> parameter.  It takes two pointers.
>> It's not about "having to" change.  It's about whether you'll notice
>> that the change affects safety.
>
> I'm still confused. If I write
>     T *p = new T; g();
> or
>     g(); T *p = new T;
> then in the first case I'll leak memory if g() throws,
> and in the second case I won't. But what does this have
> to do with safety? Obviously, if I use raw pointers then
> my code is subject to resource leaks from exceptions that
> happen afterwards.

Right.

> The point is that with a properly specified order of
> evaluation, code which tries to be safe really can be
> safe, as opposed to the f(auto_ptr, auto_ptr) mess that
> we have now. 

It's like Bob says.  Code that tries to be safe can be safe today.  It
just has to try the right way.  And that will be true tomorrow, even
if we specify order of evaluation.

The _fundamental_ problem with the auto_ptr case above isn't an
unspecified order of evaluation.  It's allowing/encouraging the casual
user to expose unmanaged resources in the first place

> Code that doesn't try to be safe is going
> to get only slightly safer, in that it won't be subject
> to the compiler's arbitrary reorderings, but latent
> resource leaks aren't going to go away by themselves.

Exactly my point.

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]



