C++ exceptions are broken in FreeBSD with gcc-compiled code?
Alexander Kabaev
kabaev at gmail.com
Wed Apr 9 19:17:08 UTC 2008
On Wed, 09 Apr 2008 09:39:09 -0700
Yuri <yuri at rawbw.com> wrote:
> I am unable to make a C++ program to catch an exception using the the
> system g++ compiler.
% c++ -o exc exc.c
% ./exc
Caught an exception "String"
% c++ -O2 -pthread -o exc exc.c
% ./exc
Caught an exception "String"
% c++42 -O2 -pthread -o exc exc.c
% ./exc
Caught an exception "String"
% c++42 -O2 -o exc exc.c
% ./exc
Caught an exception "String"
% cat exc.c
#include <iostream>
#include <string>
using namespace std;
int
main()
{
try {
throw string("String");
} catch (string s) {
cout << "Caught an exception \"" << s << "\"\n";
}
return 0;
}
% uname -a
FreeBSD kan.dnsalias.net 8.0-CURRENT FreeBSD 8.0-CURRENT #0: Sun Apr 6
14:22:23 EDT 2008 ...
Same on RELENG_6 (do not have 7.0 around, but 8.0 and 7.0 are identical
compiler-wise. Same on 8.0/amd64.
BTW, do you have . in your PATH?
> g++ -fexceptions -o exc exc.C
> exc <==== should it be ./exc ?
Exception raised: Memory allocation failure!
^^^^^^^^^^^ Not in your sample code.
--
Alexander Kabaev
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-hackers/attachments/20080409/f817a047/signature.pgp
More information about the freebsd-hackers
mailing list