public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Sol Foster <colomon@ralf.org>
To: egcs@cygnus.com
Subject: Re: malloc/free & new/delete balance
Date: Tue, 30 Jun 1998 14:46:00 -0000	[thread overview]
Message-ID: <199806301651.MAA24055@maniac.deathstar.org> (raw)

Alexandre Oliva <oliva@dcc.unicamp.br> wrote:
> 
> Carlo Wood <carlo@runaway.xs4all.nl> writes:
> 
> > WEAK (void operator delete[] (void *ptr) throw ())
> > {
> >   if (ptr)
> >     free (ptr);
> > }
> 
> > 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 the pointer it is
> given.  

Huh?  It's correct in the Nov'96 paper.  "For such a non-null value of
ptr, reclaims storage allocated by the earlier call to the default
operator new[]."  Nothing about free in there.  You mean they changed it
to something obviously incorrect?  *None* of the deletes should be defined
in terms of free...  (Implemented, sure, but not defined.)

> So, I'd say the implementation is correct, and calling operator
> delete(void*) is non-standard.  Too bad. :-(

While it isn't that hard to get around (just replace the all operators 
with your own) it seems a shame to allow an obvious mistake like this into
EGCS.


-- 
Sol Foster: colomon@ralf.org

A genius is someone who travels to truth by an unexpected path.
Unfortunately, unexpected paths lead to disaster in everyday life.  
                                        -Alfred Bester

             reply	other threads:[~1998-06-30 14:46 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-06-30 14:46 Sol Foster [this message]
     [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-07-01 22:54 Mike Stump
1998-07-02  1:39 ` Alexandre Oliva
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=199806301651.MAA24055@maniac.deathstar.org \
    --to=colomon@ralf.org \
    --cc=egcs@cygnus.com \
    /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).