Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!weretis.net!feeder4.news.weretis.net!news.cgarbs.de!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!news.glorb.com!border3.nntp.dca.giganews.com!Xl.tags.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local2.nntp.dca.giganews.com!news.giganews.com.POSTED!not-for-mail NNTP-Posting-Date: Tue, 26 Apr 2011 11:10:07 -0500 Return-Path: Sender: std-cpp-request@vandevoorde.com Approved: james.dennett@gmail.com Message-ID: Newsgroups: comp.std.c++ From: =?ISO-8859-1?Q?Daniel_Kr=FCgler?= Subject: Re: noexcept-specification vs returning a prvalue Organization: A noiseless patient Spider References: <83f4aba6-91b5-4c95-b298-46cc269651ee@r23g2000vbp.googlegroups.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed X-Original-Date: Tue, 26 Apr 2011 14:34:49 +0200 X-Submission-Address: std-c++-submit@vandevoorde.com To: undisclosed-recipients:; Date: Tue, 26 Apr 2011 11:05:03 CST Lines: 69 X-Usenet-Provider: http://www.giganews.com X-Trace: sv3-KZyN0hmd6dwl/WRX229YxL/jbTasY4MklwlAaIfL9ERM/uFrVoHYTLG9rgtfK4dhpNXDEGaNm+gis8Q!2yAfNLYWtzRqoShNj/wMIPUqEeWgf04ZRbfEfn/CFmynN/4bSww= X-Complaints-To: abuse@giganews.com X-DMCA-Notifications: http://www.giganews.com/info/dmca.html 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.40 X-Original-Bytes: 3506 Xref: x330-a1.tempe.blueboxinc.net comp.std.c++:127 On 2011-04-23 18:21, Nikolay Ivchenkov wrote: > > Consider the following example: > > #include > > struct C > { > C(); > C(C const&) noexcept(false); > }; > > C f() noexcept(true); > > int main() > { > std::cout<< (int)noexcept(f()); > } > > Here f is declared with non-throwing exception-specification, though > copy constructor of its return type does not have non-throwing > exception-specification. What is the value of expression noexcept(f())? I think the FDIS says that noexcept(f()) shall evaluate to "true" in this example. My interpretation is based on the way how I read the meaning of "A function is said to allow" in [except.spec] p. 8 (complemented by p. 12) to refer to exceptions that are possibly invoked by the function implementation including its return statement. The return statement includes the construction and possible move/copy of the return value of f() as explained in [stmt.return] p. 2: "A return statement can involve the construction and copy or move of a temporary object (12.2)." so the tagging of f with noexcept(true) means that we are sure that the function call including the construction and possible copy [move is not possible here] of the return value) does no throw an exception. It seems to me that this does not include the destruction of the temporary, so extending the definition of C like struct C { C(); C(C const&) noexcept(false); ~C noexcept(false); }; should change the value of noexcept(f()) to false, because the noexcept operator also considers the destruction of the temporary of the complete function call expression. It could be helpful, if [except.spec] p. 8 and/or p. 12 would be clearer in this regard. HTH & Greetings from Bremen, Daniel Krügler -- [ comp.std.c++ is moderated. To submit articles, try posting with your ] [ newsreader. If that fails, use mailto:std-cpp-submit@vandevoorde.com ] [ --- Please see the FAQ before posting. --- ] [ FAQ: http://www.comeaucomputing.com/csc/faq.html ]