Arrays/containers and destructors that throw

Arrays/containers and destructors that throw

Post by Usene » Mon, 28 Feb 2005 00:41:30


I could swear that behavior is undefined if we have an array or standard
container of a type with a destructor that throws, but I'll be darned if I
can find the wording for this. Regarding containers, 17.4.4.8/3 says

No destructor operation defined in the C++ Standard Library will throw
an exception.

But that applies only to the containers themselves.

17.4.3.6/2 says that behavior is undefined as follows:

for types used as template arguments when instantiating a template
component, if the operations on the type do not implement the semantics
of the applicable Requirements subclause (20.1.5, 23.1, 24.1,
26.1). Operations on such types can report a failure by throwing an
exception unless otherwise specified.

Nothing I can find in the cited clauses prohibits types whose destructors
throw.

Can somebody please point me to the parts of the standard that say what
happens when arrays or standard containers hold types whose destructors
throw?

Thanks,

Scott

---
[ 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.yqcomputer.com/ ]
 
 
 

Arrays/containers and destructors that throw

Post by smeyer » Tue, 01 Mar 2005 07:00:45

[This is a repost as the original from two days ago has yet to appear...]

I could swear that behavior is undefined if we have an array or standard
container of a type with a destructor that throws, but I'll be darned if I
can find the wording for this. Regarding containers, 17.4.4.8/3 says

No destructor operation defined in the C++ Standard Library will throw
an exception.

But that applies only to the containers themselves.

17.4.3.6/2 says that behavior is undefined as follows:

for types used as template arguments when instantiating a template
component, if the operations on the type do not implement the semantics
of the applicable Requirements subclause (20.1.5, 23.1, 24.1,
26.1). Operations on such types can report a failure by throwing an
exception unless otherwise specified.

Nothing I can find in the cited clauses prohibits types whose destructors
throw.

Can somebody please point me to the parts of the standard that say what
happens when arrays or standard containers hold types whose destructors
throw?

Thanks,

Scott

---
[ 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.yqcomputer.com/ ]

 
 
 

Arrays/containers and destructors that throw

Post by dhel » Tue, 01 Mar 2005 07:01:25


I find http://www.yqcomputer.com/ ++/eh/dtor-1.xhtml to be
quite informative. Hope it helps.

Dave

---
[ 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.yqcomputer.com/ ]
 
 
 

Arrays/containers and destructors that throw

Post by dave » Tue, 01 Mar 2005 07:01:45


XXXX@XXXXX.COM (Scott Meyers) writes:


You just gave up reading too soon.

17.4.3.6

-1- In certain cases (replacement functions, handler functions,
operations on types used to instantiate standard library template
components), the C++ Standard Library depends on components supplied
by a C++ program. If these components do not meet their requirements,
the Standard places no requirements on the implementation.

-2- In particular, the effects are undefined in the following cases:

<snip>

--- if any replacement function or handler function or destructor
operation throws an exception, unless specifically allowed in
the applicable Required behavior paragraph.

I'm not sure there's a similar rule for built-in arrays.


HTH,
--
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.yqcomputer.com/ ]
 
 
 

Arrays/containers and destructors that throw

Post by Michael Pr » Tue, 01 Mar 2005 20:05:22

> Can somebody please point me to the parts of the standard that say

according to
http://www.yqcomputer.com/
container for such objects will stop providing you with any guarantee
about exception safety.



:)
And if you read a bit further:
17.4.3.6/2
"In particular, the effects are undefined in the following cases:
..
- if any replacement function or handler function or *destructor*
operation throws an exception, unless specifically allowed in
applicable Required behavior pharagraph."

Bye.
Sincerely yours, Mike.

---
[ 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.yqcomputer.com/ ]
 
 
 

Arrays/containers and destructors that throw

Post by dave » Wed, 02 Mar 2005 02:48:46

"Michael Pryhodko" < XXXX@XXXXX.COM > writes:


That's a pre-standard document and shouldn't be relied on for
information about what's standard in C++98 and beyond.
--
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.yqcomputer.com/ ]