Topic: (none)


Author: Carlo Pescio <pescio@acm.org>
Date: 1997/02/19
Raw View
Is the following code legal? What I'm trying to do is to detect the type of
the unhandled exception inside a terminate handler. It works on some
compilers (es. Borland 4.0), but it fails (abort) on others (es. Visual C++
4.0 and 5.0).
Reading the April '96 DWP, I haven't found a definitive answer...
I'd appreciate if you could also email me any answer, as sometimes the
articles does not appear at my newsserver.
Thanks,
Carlo

#include <iostream.h>
#include <except.h>

void f()
  {
  try
    {
    throw ;
    }
  catch( int x )
    {
    cout << "integer exception" ;
    }
  catch( ... )
    {
    cout << "other exception" ;
    }
  exit( 1 ) ;
  }

int main()
  {
  set_terminate( f ) ;
  throw "a" ;
  return 0 ;
  }




+------------------------------------------------------------------------+
| Dr. Carlo Pescio        Email: pescio@acm.org                          |
| Eptacom Consulting             pescio@programmers.net                  |
| Via B. Forte 2-3               pescio@mbox.vol.it                      |
| 17100 Savona - ITALY    Home:  http://www.programmers.net/artic/Pescio |
| Fax: +39-19-854761                                                     |
+------------------------------------------------------------------------+
---
[ comp.std.c++ is moderated.  To submit articles: Try just posting with your
                newsreader.  If that fails, use mailto:std-c++@ncar.ucar.edu
  comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
  Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
  Comments? mailto:std-c++-request@ncar.ucar.edu
]