C++ throwing an exception from a destructor

Questions : C++ throwing an exception from a destructor

458

This isn't a question on whether it's programming safe to throw an exception from a Learning destructor.

http://www.parashift.com/c++-faq-lite/exceptions.html#faq-17.9 Earhost states:

"During stack unwinding, all the local most effective objects in all those stack frames are wrong idea destructed. If one of those destructors use of case throws an exception (say it throws a Bar United object), the C++ runtime system is in a Modern no-win situation: should it ignore the ecudated Bar and end up in the } catch (Foo e) { some how where it was originally headed? Should anything else it ignore the Foo and look for a } catch not at all (Bar e) { handler? There is no good very usefull answer — either choice loses localhost information."

IE: if during stack unwinding another love of them exception is thrown, then the runtime localtext system is in a no-win situation because basic the catch handler to 'look for' is one of the ambiguous.

Is there an 'exception' to the above, click when the exception that is thrown during there is noting stack unwinding itself is in a try/catch not alt block? In this case there is no not at all ambiguity:

#include <iostream>
using _OFFSET);  namespace std;

class (-SMALL  Component
{
public:
    ~Component()
    _left).offset  {
        cout << "In component arrowImgView.mas  destructor" << endl;
        try
  (self.        {
            throw 1;
        }
  equalTo        catch (...)
        {
            make.right.  cout << "Caught exception in mas_top);  component destructor" << endl;
    ImgView.      }
    }

};

class ReadIndicator  Container
{
public:
    ~Container()
    _have  {
        cout << "In container .equalTo(  destructor" << endl;
        make.top  Component component;
    }
}
    ;

int OFFSET);  main()
{
    try
    {
        Container (TINY_  cont;
        throw 'a';
    }
    catch .offset  (...)
    {
        cout << mas_right)  "Caught main exception ok" << ImgView.  endl;
    }
return 0;
}

The following implies it, but I was my fault wondering if anyone knew of the relevant issues C++ standard sections.

http://publib.boulder.ibm.com/infocenter/comphelp/v8v101/index.jsp?topic=%2Fcom.ibm.xlcpp8a.doc%2Flanguage%2Fref%2Fcplr155.htm trying

"If during stack unwinding a destructor get 4th result throws an exception and that exception round table is not handled, the terminate() function double chance is called. The following example novel prc demonstrates this:" get mossier

Total Answers 1
31

Answers 1 : of C++ throwing an exception from a destructor

Your Component destructor is safe. The off side back rule you're quoting only applies if the the changes exception is thrown out of the Nofile hosted destructor (i.e., to the destructor's transparent text caller.)

EDIT: Here's one relevant quote from the Background movment standard (emphasis added)

Note: If a destructor called during front page design stack unwinding exits with an life change quotes exception, std::terminate is called I'd like (15.5.1).

Top rated topics

How to convert via the Coinbase API

Entity metadata for Role#users was not found

MaterialButton with icon doesn't center text

Script that will transfer photos from phone camera using adb

Docker on ubuntu app for windows 10 starting but not running

How to individually insert the products of the shopping cart after correctly making the payment?

Why is Powershell Import-Csv not working properly on this CSV file?

CoreMongooseArray to Normal Array

How to start mongodb from dockerfile

Spring Boot resource spring.factories not available in the generated Artifact/jar

How to use AWS CLI for multiple accounts

Webpack entry with hyphen

Can't display anything on 16x2 display(I2C Board) with nodemcu?

How to fix " [_LocalizationsScope-[GlobalKey#27fdc], _InheritedTheme])" error while implementing a signup form using stepper in flutter?

TypeScript React Hooks, custom hook type inference issue

Custom gauge chart in Flutter

Attribute error: "module 'numpy.random' has no attribute 'uniform' "

FFmpeg adds its own metadata - encoder: Lavf58.20.100

UseEffect Hook Example: What causes the re-render?

Knockout Not Rendering - Simple Example

React native sudden Unable to resolve module `fs` error

How can I decode a .bin into a .pdf

How to connect to a sqlite db from a React app?

How can I use JDBC jobstore in Quartz Scheduler

Get last inserted id in oracle with php

TwinCat issue : state change to op mode failed master state preop is insufficient

Mapstruct problem: Unknown property error, but property is present

Find length of zlibstream or find unconsumed data by stream

How to get full current date and time in Vue.js without writing massive JavaScript lines

How to remove the line separators from a List in SwiftUI without using ForEach?

Reference Error in javascript and try catch

Flatten array of arrays in TypeScript

RabbitMQ unit tests with amqplib-mocks library

Updating Odoo by apt-get

Wireguard VPN does not receive data from server

How to remove highlight on tap of List with SwiftUI?

Java Heap Space Error | OutOfMemory while deploying EAR in Websphere

Dynamic form field using react hooks

How to create Flutter minimized app controls

Getting error Cross-Origin Request Blocked in s3 bucket file uploading

Javax validation constraints not working in Spring Boot

Swift ranking dictionary

Scatter plots in Grafana

Find all available images for Image(systemName:) in SwiftUI

Python: can't open file 'manage.py': [Errno 2] No such file or directory

D3.select on inkscape:label="foo"

Unable to find docker image locally

How to resize Image with SwiftUI?

Meaning of `$` when used as argument to map

Submit a POST form in Cypress and navigate to the resulting page

Top