Exceptions not working?

Mike Harrold mharrold@cas.org
Sun Jan 3 09:02:00 GMT 1999


Hi,

  The code below fails to catch the exception thrown if the
program is executed without any arguments on the
i386-unknown-freebsd platform.

  The exception is caught on a sparc-sun-solaris2.6 platform.

#include <iostream.h>
 
class bad { };
 
int foo(int x)
{
  if (x == 1)
    throw bad();
 
  return x;
}
 
int main(int argc, char**)
{
  try
    {
      cout << foo(argc) << endl;
    }
  catch (bad)
    {
      cerr << "Ahem!" << endl;
    }
  catch (...)
    {
      cerr << "Very strange..." << endl;
    }
 
  return 0;
}

  Is there a known problem with exceptions on the freebsd platforms?
Btw, this is egcs-1.0.3a.

/Mike



More information about the Gcc-bugs mailing list