This is the mail archive of the egcs@egcs.cygnus.com mailing list for the EGCS project. See the EGCS home page for more information.
It does seem to work in recent egcs on sparc, at least.
Take the following code:
//------------------------------
#include <new>
struct A
{
int a;
A();
};
A::A()
{
a = 5;
}
void f()
{
struct A *p;
p = new (nothrow) A;
}
Run it thru g++ -Wall -S -fno-handle-exceptions. This yields:
.file "a.C"
gcc2_compiled.:
.section ".rodata"
.align 8
.LLC0:
.asciz "bad_alloc"
.section ".text"
.align 4
.global __1A
.type __1A,#function
.proc 0110
__1A:
!#PROLOGUE# 0
save %sp, -112, %sp
!#PROLOGUE# 1
mov %i0, %o0
mov 5, %o1
st %o1, [%o0]
.LL16:
mov %o0, %i0
b .LL15
nop
.LL15:
ret
restore
.LLfe1:
.size __1A,.LLfe1-__1A
.align 4
.global f__Fv
.type f__Fv,#function
.proc 020
f__Fv:
!#PROLOGUE# 0
save %sp, -120, %sp
!#PROLOGUE# 1
mov 4, %o0
sethi %hi(nothrow), %o2
or %o2, %lo(nothrow), %o1
call __nw__FUiRC9nothrow_t, 0
nop
mov %o0, %l0
cmp %l0, 0
be .LL18
nop
mov %l0, %o0
call __1A, 0
nop
st %o0, [%fp-20]
b .LL19
nop
.LL18:
st %l0, [%fp-20]
.LL19:
.LL17:
ret
restore
.LLfe2:
.size f__Fv,.LLfe2-f__Fv
.ident "GCC: (GNU) egcs-2.93.05 19990207 (gcc2 ss-980929 experimental)"
Notice the
mov %o0, %l0
cmp %l0, 0
be .LL18
sequence right after the call to new (nothrow) and right before the call
to A's constructor. What are you missing there ? The pointer checking code
is emitted at new's site, not within the constructor. Do you have a
symptomatic case where more is needed ?