[970929] Can't throw in constructor
H.J. Lu
hjl@lucon.org
Mon Oct 6 19:57:00 GMT 1997
>
> Good news: Debian finally has a glibc 2.0.5c, so I can use
> egcs-970929:
>
> Reading specs from /usr/local/lib/gcc-lib/i486-pc-linux-gnu/egcs-2.90.11/specs
> gcc version egcs-2.90.11 970929 (gcc2-970802 experimental)
>
> # This directory was configured as follows:
> SRC/configure --host=i486-pc-linux-gnu --program-transform-name=s,^,s, \
> --norecursion
> # using "SRC/config/mt-linux"
>
> Bad news: My exception-in-constructor test case fails. (It's compiled
> with "-g", no optimization, with "-frtti":
>
> -----------------------------------------------------------------------
> #include <iostream.h>
> #include <sys/types.h>
>
>
> char x[100];
> class Noisy {
> public:
> Noisy() { throw "Aaaaah!"; }
>
> void * operator new (size_t)
> { cout << "Noisy::new" << endl; return x; }
> void operator delete (void *, size_t)
> { cout << "Noisy::delete" << endl; }
> };
>
> void
> foo()
> {
> Noisy *p = 0;
> try {
> p = new Noisy;
> delete p;
> }
> catch (...) {
> cout << "Can't be noisy" << endl;
> }
> }
>
> main()
> {
> foo();
> }
I got
# gcc -O e.cc
# a.out
Noisy::new
Can't be noisy
under Linux with libc 5.4.39 and glibc 2.1.
H.J.
More information about the Gcc
mailing list