This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Are exception with gcc 2.95.2 thread-safe?
- To: aurelien dot cornet at tms dot thomson-csf dot com
- Subject: Re: Are exception with gcc 2.95.2 thread-safe?
- From: Loren James Rittle <rittle at latour dot rsch dot comm dot mot dot com>
- Date: Tue, 21 Mar 2000 16:56:51 -0600 (CST)
- CC: gcc at gcc dot gnu dot org
- Reply-to: rittle at rsch dot comm dot mot dot com
> I try the attached progam on Linux, Sun, Aix:
> In a main procedure, a try block creates a thread, sleep 2s (let the
> thread to be run), then throw an exception. We expected that this
> exception will be catched in main and the program terminates. But this
> program will never terminate and the result is:
> Thread has started
> Exception catched in thread
> Is it a bug? Can we use exception in a multi-threading program?
Your program is operating as it should in the three environments I
have easy access to: Solaris, Linux and FreeBSD. I suspect that there
is a reason why it isn't working for you.
Unfortunately, when you configure gcc, you have to explicitly inform
the process that you want thread safety! E.g.:
../egcs/configure --enable-threads
Then, you have to provide a non-portable-between-gcc-based-
development-environments switch during both compilation and linking:
On Linux and FreeBSD:
g++ -pthread main.C
On Solaris:
g++ -pthreads main.C
On OSF:
EITHER g++ -pthread main.C OR g++ -threads main.C
(but note that depending on which switch you give, your program will
link against a different set of libraries)
Don't ask me why you need to use different options... ;-)
Regards,
Loren