c++/2723: exception handling

jle@star.be jle@star.be
Thu May 3 02:36:00 GMT 2001


>Number:         2723
>Category:       c++
>Synopsis:       exception handling
>Confidential:   no
>Severity:       critical
>Priority:       high
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu May 03 02:36:00 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     Jacques Leroy
>Release:        gcc version 2.95.3 20010315 (release)
>Organization:
>Environment:
hppa2.0-hp-hpux10.20
(using gas 2.10.1)
>Description:
throwing an axception cause a Memory Fault

happens only on hppa2.0-hp-hpux10.20

Very nasty bug preventing CORBA-related product to work safely...
>How-To-Repeat:
class Ex() {
public:
Ex() {}
};

int main(int argc, char *argv[]) {
  try {
    throw Ex();
    return 1;
  } catch (const Ex& e) {
    return 0;
  } catch (...) {
    return 1;
  }
  return 1;
}
// this will crash in flame
>Fix:
// simply add include of std exception
#include <exception>

// derive from std::exception
class Ex() : public std::exception {
public:
Ex() {}
};

int main(int argc, char *argv[]) {
  try {
    throw Ex();
    return 1;
  } catch (const Ex& e) {
    return 0;
  } catch (...) {
    return 1;
  }
  return 1;
}

// and it's working !
>Release-Note:
>Audit-Trail:
>Unformatted:



More information about the Gcc-prs mailing list