See testcase

STABLE:

[EMAIL PROTECTED]:~/cxxtest2$ export LD_LIBRARY_PATH=.
[EMAIL PROTECTED]:~/cxxtest2$ ./a.out
cought string: x == 1
bar: cought string: x == 1
[EMAIL PROTECTED]:~/cxxtest2$ ./b.out
cought string: x == 1
bar: cought string: x == 1

CURRENT:

[EMAIL PROTECTED]:~/cxxtest2$  ./a.out
cought string: x == 1
bar: cought string: x == 1
[EMAIL PROTECTED]:~/cxxtest2$ ./b.out
Abort trap (core dumped)

cxxtest2/Makefile
----------------------------------------------------
CXX=g++
LD=ld
CXXFLAGS=-fpic -fexceptions

all: a.out b.out

#
# Works
#
a.out: main.o foo.so bar.so
        ${CXX} -o a.out main.o foo.so bar.so

#
# Broken
#
b.out: main.o foo2.so bar2.so
        ${CXX} -o b.out main.o foo2.so bar2.so

#
# Works
#
bar.so: bar.o
        ${CXX} -shared -o bar.so bar.o

foo.so: foo.o
        ${CXX} -shared -o foo.so foo.o

#
# Broken
#
bar2.so: bar.o
        ${LD} -Bshareable -o bar2.so bar.o

foo2.so: foo.o
        ${LD} -Bshareable -o foo2.so foo.o

clean:
        rm -f a.out *.o *.so
----------------------------------------------------

cxxtest2/bar.cc
----------------------------------------------------
/* compile with "g++ -shared -fPIC -o bar.so bar.cc" */

#include <iostream>
#include <string>

using namespace std;
using std::cerr;

extern void foo(int);
void bar(int x)
{
    try {
        foo(x);
    } catch (string s) {     cerr << "bar: cought string: " << s << endl;
    } catch (int i) {     cerr << "bar: cought int: " << i << endl;
    } catch (...) {     cerr << "bar: cought something" << endl;
    }
}
----------------------------------------------------

cxxtest2/foo.cc
----------------------------------------------------
/* compile with "g++ -shared -fPIC -o foo.so foo.cc" */
#include <string>

using namespace std;

void foo(int x)
{
    switch(x) {
    case 1:
        throw string("x == 1");
    case 2:
        throw int(2);
    default:
        throw float(3.1415);
    }
}
----------------------------------------------------

cxxtest2/main.cc
----------------------------------------------------
/* compile with "g++ main.cc ./foo.so ./bar.so" */
#include <string>
#include <iostream>

using namespace std;

extern void foo(int);
extern void bar(int);
main(int argc, char *argv[])
{
    try {
        foo(argc);
    } catch (string s) {     cerr << "cought string: " << s << endl;
    } catch (int i) {     cerr << "cought int: " << i << endl;
    } catch (...) {     cerr << "cought something" << endl;
    }
    bar(argc);
    return 0;
}
----------------------------------------------------

Martin Blapp, <[EMAIL PROTECTED]> <[EMAIL PROTECTED]>
------------------------------------------------------------------
ImproWare AG, UNIXSP & ISP, Zurlindenstrasse 29, 4133 Pratteln, CH
Phone: +41 61 826 93 00 Fax: +41 61 826 93 01
PGP: <finger -l [EMAIL PROTECTED]>
PGP Fingerprint: B434 53FC C87C FE7B 0A18 B84C 8686 EF22 D300 551E
------------------------------------------------------------------

To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-current" in the body of the message

Reply via email to