CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums
Results 1 to 3 of 3

Thread: Unexpected Output

  1. #1

    Unexpected Output

    Function funExceptionHandler is not getting called though exception is thrown

    #include <iostream>
    #include <exception>
    using namespace std;
    void funExceptionHandler () {
      cerr << "unexpected handler called\n";
    void fun () throw (int) {
      throw 1.11; // throws double (not in exception-specification)
    int main (void) {
      set_unexpected (funExceptionHandler);
      try {
      catch (double) { cerr << "caught double\n"; }
      catch (...) { cerr << "caught other exception (non-compliant compiler?)\n"; }
      return 0;

  2. #2
    Join Date
    Jul 2002
    Portsmouth. United Kingdom

    Re: Unexpected Output

    When I compile the example (VC2008) I get this warning.

    warning C4290: C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
    "It doesn't matter how beautiful your theory is, it doesn't matter how smart you are. If it doesn't agree with experiment, it's wrong."
    Richard P. Feynman

  3. #3
    Join Date
    Jun 2009

    Angry Re: Unexpected Output

    Didn't I answer this yesterday?
    Is your question related to IO?
    Read this C++ FAQ article at parashift by Marshall Cline. In particular points 1-6.
    It will explain how to correctly deal with IO, how to validate input, and why you shouldn't count on "while(!in.eof())". And it always makes for excellent reading.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)