🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

2 total messages Started by Don Organ Sat, 09 Mar 1996 04:39
Exceptions: function-try-block
#3629
Author: Don Organ
Date: Sat, 09 Mar 1996 04:39
54 lines
2349 bytes
In reading Chapter 15 - Exception handling in the April '95 Draft,
I saw something that looked new to me:

function-try-block:
	try ctor-initializer-opt function-body handler-seq

Where
	try is a literal,
	ctor-initializer (without the -opt) is defined in section
		12.6.2 "Initializing bases and members"
	function-body is defined in section 8.4 "Function Definitions"
	handler-seq is the series of catch statements.
function-try-block is referenced from section 8.4 as one of the 2 forms
of a function-definition.

They way I interpret all of this is that the following
should be legal:

class X {
public:
	X(int arg1=0);

	int member1;
	int member2;
};

X::X(int arg1) try : member1(0), member2(0)
{
}
catch (...) {};

I.e. the try keyword precedes both the colon and the member initializer
list and the catch keyword is not contained in a block.
The catch handler would be entered if any exceptions were thrown
either from the member initializers (not likely in this case since the
members are simple types) are the body of the constructor.

What is the correct interpretation?
Is there any published material regarding usage of this form?
Are there any compilers that support this form?


=======================================
Don Organ     dorgan@mtest.teradyne.com
Direct: 408-441-3123  FAX: 408-451-3201
The Megatest Division of Teradyne, Inc.
880 Fox Lane San Jose, CA    95131-1685
=======================================
---
[ 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         ]
[ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
[ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]
Re: Exceptions: function-try-block
#3632
Author: Steve Clamage
Date: Sun, 10 Mar 1996 02:36
46 lines
2176 bytes
dorgan@mtest.teradyne.com (Don Organ) writes:

>They way I interpret all of this is that the following
>should be legal:

>class X {
>public:
>	X(int arg1=0);

>	int member1;
>	int member2;
>};

>X::X(int arg1) try : member1(0), member2(0)
>{
>}
>catch (...) {};

>I.e. the try keyword precedes both the colon and the member initializer
>list and the catch keyword is not contained in a block.
>The catch handler would be entered if any exceptions were thrown
>either from the member initializers (not likely in this case since the
>members are simple types) are the body of the constructor.

That is correct.

>Is there any published material regarding usage of this form?

As far as I know, only the draft standard. This new form of try-block
was introduced to solve the problem of exceptions thrown during
member or base initialization, before the body of the constructor
is entered. Previously, there was no way to find out if any such
exceptions occurred or deal with them.

>Are there any compilers that support this form?

I don't know which ones support it yet, if any. Eventually all will.

--
Steve Clamage, stephen.clamage@eng.sun.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         ]
[ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
[ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads