0

Possible Duplicates:
How is the C++ exception handling runtime implemented?
How do exceptions work (behind the scenes) in c++

Dear All,

I want to know, how C++ exception is implemented ?

Is it actually using Setjump() & Longjump() concepts as in build?

Community
  • 1
  • 1
osdevkid
  • 137
  • 2
  • 3
  • 14
  • http://stackoverflow.com/questions/490773/how-is-the-c-exception-handling-runtime-implemented – kqnr Jun 01 '11 at 05:03
  • Duplicate of http://stackoverflow.com/questions/307610/how-do-exceptions-work-behind-the-scenes-in-c and http://stackoverflow.com/questions/490773/how-is-the-c-exception-handling-runtime-implemented – HostileFork says dont trust SE Jun 01 '11 at 05:04

2 Answers2

2

The standard does not define how exceptions have to be implemented by the compiler vendors. The two main strategies are to keep track of catch locations in a table or to unwind the stack frames until a suitable catch site is found.

MSVC for example uses SEH (Structured Exception Handlers) to implement C++ exceptions, while GCC uses a pure address table approach. Other compilers still, may use stack unwinding if they preserve enough frame information.

xDD
  • 3,443
  • 1
  • 15
  • 12
1

You should check Section 15.1 Throwing an exception of the standard.

Alok Save
  • 202,538
  • 53
  • 430
  • 533
  • 2
    @osdevkid: It's impossible to provide a link to the standard. ISO charges for it. – Billy ONeal Jun 01 '11 at 05:14
  • You can however view the latest drafts of each standard, which are for your purposes identical to the final document from ISO: http://www.open-std.org/jtc1/sc22/wg21/ – xDD Jun 01 '11 at 05:18