malloc/free & new/delete balance

Alexandre Oliva oliva@dcc.unicamp.br
Thu Jul 2 01:39:00 GMT 1998


Mike Stump <mrs@wrs.com> writes:

>> Agreed, but, for some reason, the FDIS [lib.new.delete.array]
>> defines operator new[](size_t) as returning operator new(size_t) by
>> default, while it states that operator delete[](void*) frees

> Can you provide an exact quote of this?  I can't find it.  I'll quote
> from the FDIS below.

I didn't write delete[] calls free(), I just said it frees
(deallocates) the memory.  No where it says delete[] calls delete by
default, and, since it does for new[] and new, I took it as a
difference, rather than as an omission.

> The next stage of your learning is to be able to say when the standard
> is wrong.  :-)

:-)

> Also, I think we are staring at different papers.  Does yours have the
> number 14882 or X3J16/97-0079 on it?  If not, that isn't the FDIS, and
> you should not call it that.

Actually, mine is an html-ized version that has no such numbers, it
just says `November 1997 Draft Standard'.  AFAIK, it contains all the
text from the FDIS.

>> From the real FDIS:

> -12- Default behavior: 
[snip]
>        For such a non-null value of ptr , reclaims storage allocated
>        by the earlier call to the default operator new[].

-- 
Alexandre Oliva
mailto:oliva@dcc.unicamp.br mailto:aoliva@acm.org
http://www.dcc.unicamp.br/~oliva
Universidade Estadual de Campinas, SP, Brasil




More information about the Gcc mailing list