This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Q: Catch a segmentation fault


Hi!

I'm new to this list. I don't know if this question belongs to it but I have
failed to find any information about my problem elsewhere so I turn to you.

We're currently developing code on i386 on both Linux and Windows and one of
the Win32-programmers put in some code to catch segmentation faults. It
works fine on Windows but fails to catch it on Linux.

This is an example.

#include <iostream.h>

int main()
{
	char *zero = NULL;
	
        try
        {
                zero[0] = 'a';
        }
        catch()
        {
                std::cout <<"Catch!" <<std::endl;
        }
        return(0);
}

This gives me a segmentation fault and terminates my application. Can't I
catch this using the GCC C++ compiler?

I can catch a throw(something).

I'm running RedHat 6.2 on a P3 and use egcs-2.91.66.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]