Exceptions on Openserver, Egcs 1.1.2-pre2
Robert Lipe
robertlipe@usa.net
Wed Mar 31 23:46:00 GMT 1999
This example doesn't seem to work under Linux with the latest snapshots,
either.
(gdb) run
Starting program: /home/robertl/tmp/dag/./exception
Constructing Global
Program received signal SIGSEGV, Segmentation fault.
0x40078836 in _IO_unbuffer_write () at genops.c:734
genops.c:734: No such file or directory.
Current language: auto; currently c
(gdb) where
#0 0x40078836 in _IO_unbuffer_write () at genops.c:734
#1 0x40078869 in _IO_cleanup () at genops.c:749
#2 0x40043f29 in exit (status=0) at exit.c:62
I can't comment on the correctness of the program.
RJL
Dag Nygren wrote:
> > > I need the MICO library and configure there gives me complaints about
> > > exceptions not working with shared libraries....
> >
> > You'll just have to debug it. Product a minimal test case (and
> > 'minimal' means a tiny self-contained bag of bytes that shows what MICO
> > things is wrong, not an ftp site for it :-) and let us see what's going
> > on.
>
> OK, here we go. What is so wrong with this? (I am just learning C++,
> but have some 15 years of C experience, so it is a real question, not
> meant to provoke anyone.)
>
> OS: Openserver 5.0.5 with /usr/ccs/bin/lef/ld "downgraded" to the original
> 5.0.5, the rest is rs505a upgraded
> Compiler: EGCS 1.1.2-prerelease2 (2.91.62), with A.Montes' patch to make global
> constructors work with shared libraries
>
> Here are the files simplified from the MICO configure script :
>
> ===== lib.C =====
> #include <iostream.h>
>
> struct Global {
> Global () { cout << "Constructing Global\n"; }
> };
>
> Global gbl;
>
> #ifdef HAVE_EXCEPTIONS
> class Ex {};
> void bar ()
> {
> cout << "in bar\n";
> throw Ex();
> }
> #endif
>
> ===== exception.C ======
> extern "C" void exit(int);
>
> class Ex {};
> extern void bar ();
> int main ()
> {
> try {
> bar();
> } catch (Ex &e) {
> return 0;
> } catch (...) {
> return 1;
> }
> return 1;
> }
>
> And here is the script I used to compile them:
>
> g++ -g -DHAVE_EXCEPTIONS -fPIC -c lib.C
> g++ -g -shared -o libshex.so lib.o
> export LD_LIBRARY_PATH=.:$LD_LIBRARY_PATH
> g++ -g -o exception -L. -lshex exception.C
>
> And here is my output:
>
> dag:Ctest <ena> 744 % ./exception
> Constructing Global
> in bar
> Abort
>
> BRGDS
>
> Dag
More information about the Gcc
mailing list