From -8572245266280234376 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f78e5,972722ed514d508a X-Google-Attributes: gidf78e5,public X-Google-ArrivalTime: 2001-07-31 10:06:02 PST Path: archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!news.tele.dk!212.74.64.35!colt.net!dispose.news.demon.net!news.demon.co.uk!demon!mail2news.demon.co.uk!not-for-mail From: "Anthony Williams" Newsgroups: comp.std.c++ Subject: Re: try block as main block of a function Date: Tue, 31 Jul 2001 17:05:50 GMT Approved: Fergus Henderson , moderator of comp.std.c++ Message-ID: <9k5pi5$2sh3i$1@ID-49767.news.dfncis.de> References: <3b6061b5.1188820@news.terra.es> <9jr8bd$19vqd$1@ID-49767.news.dfncis.de> <9k34ms$2akk5$1@ID-49767.news.dfncis.de> <+5FKSWA1iaZ7Ew4q@ntlworld.com> X-Trace: mail2news.demon.co.uk 996599156 mail2news:19032 mail2news mail2news.demon.co.uk X-Complaints-To: abuse@demon.net X-Mail2News-Path: news.demon.net!mulga.cs.mu.oz.au 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) X-Orig-NNTP-Posting-Host: 47.160.2.96 X-Orig-X-Trace: fu-berlin.de 996567429 3032178 47.160.2.96 (16 [49767]) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4522.1200 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200 Lines: 78 Xref: archiver1.google.com comp.std.c++:6837 "Francis Glassborow" wrote in message news:+5FKSWA1iaZ7Ew4q@ntlworld.com... > In article <9k34ms$2akk5$1@ID-49767.news.dfncis.de>, Anthony Williams > writes > >8.4p16 says: > >"The exception being handled is rethrown if control reaches the end of a > >handler of the function-try-block of a constructor or destructor. Otherwise, > >a function returns when control reaches the end of a handler for the > >function-try-block (6.6.3). Flowing off the end of a function-try-block is > >equivalent to a return with no value; this results in undefined behavior in > >a value-returning function (6.6.3)." > > You are right. But that seems adequate for not using them except for > ctors (only fools let exception escape from dtors :) You said (in an earlier message) >Because many will forget that they automatically rethrow if you do not >do so. I hate default behaviour as it often hides errors. It seems to me that the only situation in which you would recommend using function-try-blocks is the one case in which the default behaviour that you "hate" happens, so I don't understand your position. The only case in which rethrowing occurs is for constructors/destructors. I agree that permitting exceptions to escape destructors is foolish. You agree that using function try blocks with constructors is permissible, even though this is therefore the only place where the "rethrow" default behaviour will show up. For normal functions the default behaviour is what you would naively expect, exceptions are not rethrown - you just have to ensure you code a return statement (for a value-returning-function) in the catch handler, which you would have to do anyway even if the catch was within the block int func() try { // do something } catch(...) { // do some error handling } is _identical_ in behaviour to int func() { try { // do something } catch(...) { // do some error handling } } Anthony -- Anthony Williams Software Engineer, Nortel Networks Optoelectronics The opinions expressed in this message are not necessarily those of my employer --- [ 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.research.att.com/~austern/csc/faq.html ]