From 2415059494446104900
X-Google-Thread: f78e5,a10702d4a7db0a94
X-Google-Attributes: gidf78e5,public
X-Google-Language: ENGLISH,ASCII-7-bit
Path: g2news2.google.com!news3.google.com!news.glorb.com!peer1.news.newnet.co.uk!194.159.246.34.MISMATCH!peer-uk.news.demon.net!kibo.news.demon.net!news.demon.co.uk!demon!stump.algebra.com!devnull
From: usenet@aristeia.com (Scott Meyers)
Newsgroups: comp.std.c++
Subject: Re: Why no size_t to ::operator delete?
Date: Sun, 24 Dec 2006 17:43:13 GMT
Organization: Posted via Supernews, http://www.supernews.com
Lines: 37
Sender: mail2news@demon.net
Approved: fjh@cs.mu.oz.au (Fergus Henderson , moderator of comp.std.c++)
Message-ID: <12or0edj7o61e39@corp.supernews.com>
References: <12omt8jit7rl379@corp.supernews.com> <1166881269.632200.107290@48g2000cwx.googlegroups.com>
NNTP-Posting-Host: news.news.demon.net
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: news.demon.co.uk 1166982203 10346 158.152.254.254 (24 Dec 2006 17:43:23 GMT)
X-Complaints-To: abuse@demon.net
NNTP-Posting-Date: Sun, 24 Dec 2006 17:43:23 +0000 (UTC)
X-Original-To: std-c++@mailman.ucar.edu
X-Robomod: STUMP, ichudov@algebra.com (Igor Chudov)
X-User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.8.0.9) Gecko/20061207 Thunderbird/1.5.0.9 Mnenhy/0.7.4.0
X-Virus-Scanned: amavisd-new at csse.unimelb.edu.au
X-Path: comp-std-cpp-robomod!not-for-mail
X-Received: (from fjh@localhost)
	by mulga.csse.unimelb.edu.au (8.13.8+Sun/8.13.8/Submit) id kBOHhDQZ008889;
	Mon, 25 Dec 2006 04:43:13 +1100 (EST)
X-Delivered-To: std-c++@mailman.ucar.edu
X-Authentication-Warning: mulga.csse.unimelb.edu.au: fjh set sender to devnull@stump.algebra.com using -f
X-Newsgroups: comp.std.c++
Xref: g2news2.google.com comp.std.c++:5154

Lucas Galfaso wrote:
 > Scott Meyers wrote:
 >> Can someone explain to me why having the "normal" operator delete take a
 >> size_t is impractical?

 > The answer is simple, there is nowhere to store this information, if
 > you need it, you store it. This is just another example of C++ of not
 > to make everybody pays for what just a few need.

One of us is missing something.  At class scope, operator delete may
take a size_t.  If it does, it's provided by the compiler, which
passes the size of the object.  The information is not "stored" in the
sense of a memory location holding the size -- the compiler passes a
constant.  If a pointer to a derived object via a base class pointer
is being deleted and the base destructor is not virtual, the wrong
size gets passed, but that's okay, behavior under those conditions is
undefined.

You can only delete three things: a pointer to a class type, a pointer
to a non-class type, and a void*.  My suggestion was that a global
operator delete taking a size_t could:

- For pointers to class types, get the same value that'd be passed to
   a class-specific operator delete taking a size.
- For a pointer p to a non-class type, sizeof(*p).
- for a void* pointer, zero.

None of these options requires storing anything anywhere.

Scott

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]



