From: mrs@wrs.com (Mike Stump)
To: carlo@runaway.xs4all.nl, oliva@dcc.unicamp.br
Cc: egcs@cygnus.com
Subject: Re: malloc/free & new/delete balance
Date: Wed, 01 Jul 1998 22:54:00 -0000 [thread overview]
Message-ID: <199807020117.SAA25899@kankakee.wrs.com> (raw)
> To: Carlo Wood <carlo@runaway.xs4all.nl>
> Cc: egcs@cygnus.com (egcs@cygnus.com)
> From: Alexandre Oliva <oliva@dcc.unicamp.br>
> Date: 29 Jun 1998 21:54:36 -0300
> > This unbalance between calling `::operator new(size_t)' and
> > `free(void *)' is causing troubles when `operator new(size_t)' and
> > `operator delete(void *)' are overloaded
> 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.
> the pointer it is given. So, I'd say the implementation is correct,
> and calling operator delete(void*) is non-standard. Too bad. :-(
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.
From the real FDIS:
void operator delete[](void* ptr) throw();
void operator delete[](void* ptr, const std::nothrow_t&) throw();
-9- Effects: The deallocation function
(basic.stc.dynamic.deallocation) called by the array form of a
delete-expression to render the value of ptr invalid.
-10- Replaceable: a C++ program can define a function with this
function signature that displaces the default version defined by the
C++ Standard library.
-11- Required behavior: accept a value of ptr that is null or that was
returned by an earlier call to operator new[](std::size_t) or operator
new[](std::size_t,const std::nothrow_t&).
-12- Default behavior:
For a null value of ptr , does nothing.
Any other value of ptr shall be a value returned earlier by a
call to the default operator new[](std::size_t).*
[Footnote: The value must not have been invalidated by
an intervening call to operator delete[](void*)
(lib.res.on.arguments). --- end foonote]
For such a non-null value of ptr , reclaims storage allocated
by the earlier call to the default operator new[].
-13- It is unspecified under what conditions part or all of such
reclaimed storage is allocated by a subsequent call to operator new or
any of calloc, malloc, or realloc, declared in <cstdlib>.
Note the word above, ``reclaims.'' The calls should be symmetric as
one would guess without reading the standard. In fact, it is a bug
that the standard doesn't refine the language and say exactly that it
must call delete.
next reply other threads:[~1998-07-01 22:54 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
1998-07-01 22:54 Mike Stump [this message]
1998-07-02 1:39 ` Alexandre Oliva
[not found] <199807031202.IAA26419.cygnus.egcs@maniac.deathstar.org>
1998-07-05 19:46 ` Nathan Myers
1998-07-06 14:48 ` Joern Rennecke
1998-07-06 18:52 ` John Carr
1998-07-07 1:12 ` Joern Rennecke
-- strict thread matches above, loose matches on Subject: below --
1998-07-03 7:20 Sol Foster
1998-07-03 19:30 ` Carlo Wood
1998-06-30 14:46 Sol Foster
1998-06-29 8:41 Carlo Wood
1998-06-30 1:02 ` Alexandre Oliva
1998-06-30 15:15 ` Carlo Wood
1998-06-30 14:46 ` Alexandre Oliva
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=199807020117.SAA25899@kankakee.wrs.com \
--to=mrs@wrs.com \
--cc=carlo@runaway.xs4all.nl \
--cc=egcs@cygnus.com \
--cc=oliva@dcc.unicamp.br \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).