Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6546345
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:41:46+00:00 2026-05-25T11:41:46+00:00

Consider this: void thrower () { throw 123; } struct Catcher { ~ Catcher

  • 0

Consider this:

void thrower () {
    throw "123";
}

struct Catcher {
    ~ Catcher () {
        try {thrower ();}
        catch (...) {}
    }
};

int main () {
    try {
       Catcher c;
       throw 1.23;
    }
    catch (...) {}
}

This compiles and runs without calling terminate on gcc 4.3, but according to the standard (15.5.1)

…when the exception handling mechanism, after completing evaluation of the expression to be thrown but before the exception is caught (15.1), calls a user function that exits via an uncaught exception… terminate shall be called.

When ~Catcher is called after the double has been thrown, this is “after completing evaluation…before the exception is caught” and thrower is “a user function that exits via an uncaught exception”, this satisfies the above condition. Yes, the char* is caught but only after the user function exits.

Shouldn’t terminate have been called?

To emphasise this:

void do_throw () {
    throw "123";
}

void thrower () {
    do_throw ();
    // Uncaught exception here (A)
}

struct Catcher {
    ~ Catcher () {
        try {thrower (); /* (B) */}
        catch (...) {}
    }
};

int main () {
    try {
       Catcher c;
       throw 1.23;
    }
    catch (...) {}
}

(A) happens in the context of (B), which already has an exception in progress.

So, shouldn’t terminate have been called? If not, and this is a legal situation in which we can have two simultaneous exceptions, where do we draw the line?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T11:41:47+00:00Added an answer on May 25, 2026 at 11:41 am

    Different emphasis:

    when the exception handling mechanism, after completing evaluation of the expression to be thrown but before the exception is caught (15.1), calls a user function that exits via an uncaught exception… terminate shall be called

    thrower() is a user function that exits via an exception but it is not called by the exception handling mechanism; it is called by another user function (Catcher‘s destructor) which itself is called by the exception handling mechanism and this function doesn’t exit via an exception.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Consider this void f(vector<const T*>& p) { } int main() { vector<T*> nonConstVec; f(nonConstVec);
Consider this code: void res(int a,int n) { printf(%d %d, ,a,n); } void main(void)
Consider this code: template <int N> struct X { friend void f(X *) {}
Consider this code snippet: public static void main(String[] args) { int z1 = 0;
Consider this C code: #include stdio.h int main(void) { int count = 5; unsigned
Consider this code (Java, specifically): public int doSomething() { doA(); try { doB(); }
Consider this program: #include <map> #include <vector> typedef std::vector<int> IntVector; typedef std::map<IntVector,double> Map; void
Consider this class: public class TestMap extends HashMap<String, Float> { public static void main(String[]
Consider this code, struct A {}; struct B { B(const A&) {} }; void
Consider this piece of code: struct Trade { float Price; char* time; int shares;

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.