gcc 4.3.2 libgcc_s.so exception handling broken?
xorquewasp at googlemail.com
xorquewasp at googlemail.com
Sat Jan 17 23:41:01 PST 2009
On 2009-01-17 23:07:29, Nate Eldredge wrote:
> I tried a simple example of this in C++ and it works as expected. (I am on
> 7.0-RELEASE/amd64.) So it isn't completely busted, at least.
>
> Can you post an example that exhibits the problem? Ideally, something
> complete that can be compiled and is as simple as possible. If you can do
> it with C++ rather than Ada it might be easier, so people don't have to
> install the Ada compiler. Also please mention the commands you use to
> compile, and what they output when you compile using -v, and what
> architecture you are on.
Hello.
You're right, the C++ example works here. I'm not sure why it didn't before.
Here's a C++ version:
/* main.cpp */
#include <stdio.h>
extern "C" {
extern void
c_function (void (*func)(int x));
}
void
ext_function (int x)
{
printf ("-- ext_function %d\n", x);
throw "test_error";
}
int
main (void)
{
try {
c_function (&ext_function);
} catch (...) {
printf ("caught test_error\n");
}
return 0;
}
/* c_function.c */
#include <stdio.h>
void
c_function (void (*func)(int x))
{
printf ("-- %s enter\n", __func__);
func (23);
printf ("-- %s exit\n", __func__);
}
$ uname -smir
FreeBSD 6.4-RELEASE-p1 i386 GENERIC
$ gcc43 -v
Using built-in specs.
Target: i386-portbld-freebsd6.4
Configured with: ./..//gcc-4.3.2/configure --enable-languages=c,ada --disable-nls --with-system-zlib --with-libiconv-prefix=/usr/local --program-suffix=43 --bindir=/usr/local/bin/gcc43 --libdir=/usr/local/lib/gcc-4.3.2 --prefix=/usr/local --mandir=/usr/local/man --infodir=/usr/local/info/gcc43 --build=i386-portbld-freebsd6.4
Thread model: posix
gcc version 4.3.2 (GCC)
$ c++ -v
Using built-in specs.
Configured with: FreeBSD/i386 system compiler
Thread model: posix
gcc version 3.4.6 [FreeBSD] 20060305
$ gcc43 -o c_function.o -c c_function.c -fPIC -fexceptions -g -W -Werror -Wall -std=c99 -pedantic-errors -Wno-unused-parameter
$ gcc43 -shared -Wl,-soname,c_function.so -o c_function.so c_function.o -lc
$ c++ -o main.o -c main.cpp -fexceptions -g -W -Werror -Wall -pedantic-errors -Wno-unused-parameter
$ c++ -o main-dynamic main.o c_function.so
$ c++ -o main-static main.o c_function.o
$ ./main-static
-- c_function enter
-- ext_function 23
caught test_error
LD_LIBRARY_PATH=. ./main-dynamic
-- c_function enter
-- ext_function 23
caught test_error
This example is problematic, however - the C++ compiler is 3.4.6
(I'm not sure how to compile a 4.3.2 gcc with C, Ada and C++ support).
More information about the freebsd-hackers
mailing list