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]

Exceptions thrown across c stack frames


The following bug was found using egcs-1.0.2 on a sunOS 5.5.1 platform.
It has been found that exceptions thrown from below a c generated stackframe
will not be caught by handlers above the c frame..  In the following example 
the function 

	void cfunc();

is generated by compiling cfunc.c with gcc (__NOT__ g++).


So give files:

     // file cfunc.c
     
     #ifdef __cplusplus
     extern "C" 
     void cc_func ();
     #endif
     
     #ifdef __cplusplus
     extern "C" 
     #endif
     void c_func ()
     {
       cc_func ();
     }

and 

     // file main.cc
     
     #include <stream.h>
     #include <string>
     
     #ifdef __cplusplus
     extern "C" 
     #endif
     void c_func ();
     
     main(int argc, char *argv[])
     {
       try
     	 {
     	   c_func ();
     	 }
       catch (...)
     	 {
     	   cerr << "caught" << endl;
     	 }
     }

Then if 

	% g++ -c main.cc
	% gcc -c cfunc.c
	% g++ -o xx main.o cfunc.o
	% xx
	Abort

while 

	% g++ -c main.cc
	% g++ -c cfunc.c
	% g++ -o xx main.o cfunc.o
	% xx
	caught

Since the X libraries come precompiled on our system, this bug
makes if very difficult to handle exceptions generated within
callbacks gracefully.

+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
Bruce A. Kern					(716) 722-2345
Eastman Kodak Company				kern@image.kodak.com
+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+


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