🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.os.ms-windows.programmer.win32
Article #2062

MSVC++ 2.2 exception handling

#2062
From: Paul Stephenson
Date: Thu, 12 Oct 1995 23:15
60 lines
1697 bytes
Hi -

Does MSVC++ throw a C++ exception upon an acess violation?
I compile the following program under MSVC++ 2.2, with 
exception handling enabled in the project settings, and execute
it under Windows NT 3.5. At runtime, the catch (...) exception 
handler is entered.  

My question is this: What is the type of the exception thrown
in this case?  

I can't seem to find anything in the books online.
I'd really appreciate it if someone could shed some light on
this.

Thanks --

Paul


=====================================================================


#include <windows.h>
#include <ostream.h>

int
main (int argc, char *argv [])
{
	// Does MSVC++ really throw an exception for an access violation?

	int	*p = NULL;

	try
	{
		(*p)++;	  // Clearly, an access violation :)
	}
	catch (char c)
	{
		cerr << "Caught char exception: " << c << endl;
	}
	catch (char *s)
	{
		cerr << "Caught char* exception: " << s << endl;
	}
	catch (DWORD dw)
	{
		cerr << "Caught DWORD exception: " << dw << endl;
	}
	catch (int i)
	{
		cerr << "Caught int exception: " << i << endl;
	}
	catch (...)
	{
		cerr << "Caught unspecified exception." << endl;
	}

	return 0;
}
Technical Details
Message-ID: <45k7j5$9rh@cnn.exu.ericsson.se>
Path: arc1-ca.pugleaf.net!cnn.exu.ericsson.se!news

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!cnn.exu.ericsson.se!news
From: Paul Stephenson <paul.stephenson@ebu.ericsson.se>
Newsgroups: comp.os.ms-windows.programmer.win32,comp.lang.c++
Subject: MSVC++ 2.2 exception handling
Date: 12 Oct 1995 23:15:49 GMT
Organization: Ericsson
Message-ID: <45k7j5$9rh@cnn.exu.ericsson.se>
NNTP-Posting-Host: chaos.ebu.ericsson.se
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
X-Mailer: Mozilla 1.22 (Windows; I; 32bit)