Re: OT: g++ ignoring try/catch blocks?
On Tue, Dec 27, 2011 at 09:36:10AM -0600, Nate Bargmann wrote:
> As a bit of background, the tutorial is written some years ago and I
> have found the C++ standard has tightened a few things which has
> enhanced my learning! Also, the author uses MS VC++ even though the
> book is aimed at the C++ standard of the time. It's likely that the
> code was not tested on Unix/Linux although sometimes he will note some
> differences between the platforms which indicates some feedback if not
> personal experience. Fortunately, the tutorial is not MS VC++ centric
> as near as I can tell. It's likely, then, that the try{} block in the
> program was able to intercept the exception on MS Windows at that time.
It's definitely a MS-Windows-specific feature; it's known as
"win32 structured exception handling (SEH)", and it translates hardware
exceptions (such as divide by zero) into software exceptions (i.e.
C++ exceptions). This requires special compiler support to generate
the extra code, which presumably has some effect upon performance. I
guess it would be possible to write a signal handler to cause a throw
on return to simulate the MS VC++ behaviour, but it would be quite
hairy I think.
http://msdn.microsoft.com/en-us/library/windows/desktop/ms680657(v=vs.85).aspx
http://stackoverflow.com/questions/1497068/c-gcc-how-does-gccs-c-implementation-handle-division-by-zero
Regards,
Roger
--
.''`. Roger Leigh
: :' : Debian GNU/Linux http://people.debian.org/~rleigh/
`. `' Printing on GNU/Linux? http://gutenprint.sourceforge.net/
`- GPG Public Key: 0x25BFB848 Please GPG sign your mail.
Reply to: