C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Value of size parameter to operator [] not specified in stan

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language, library and standards
View previous topic :: View next topic  
Author Message
rich_sposato
Guest





PostPosted: Sun Aug 07, 2005 1:30 am    Post subject: Value of size parameter to operator [] not specified in stan Reply with quote



I checked the C++ Standard to see if it requires a value for the size
parameter to operator delete []. Nothing I found in sections 5.3.5,
3.7.3.2, or 18.4.1.2 specifies what is passed into the size parameter
for
void operator delete [] ( void * place, std::size_t size ) throw ();


There is enough variation among compilers when providing a value for
the size parameter that I can't write a simple, safe, and portable
operator delete [] for the Loki library.

For example:
GCC 3.4.2 makes size = ( sizeof(T) * count ) + delta.
MSVC 7.1 makes size = sizeof(T).

Of course, the count is the number of T objects in the array, and delta
is the size in bytes of any compiler overhead.

(I also checked what values are passed into the single object form of
operator delete. All the compilers passed in sizeof(T).)


I would like the ISO C++ Committee to make one small refinement to the
standard so that all compilers pass in the same size value to operator
delete [].



Here is my suggested wording:
3.7.3.2 Deallocation functions
[basic.stc.dynamic.deallocation]
Amend this sentence in paragraph 2 to read as follows. (All I did was
add the final clause to the sentence. The rest remains identical to
what is in the standard already.)

"If class T does not declare such an operator delete [] but does
declare a member deallocation function named operator delete [] with
exactly two parameters, the second of which has type std::size_t, then
this function is a usual deallocation function, and the value for the
std::size_t parameter shall be identical to the value passed into the
"void * new [] (std::size_t size )" when the memory was allocated.
(See Section 5.3.4.12)"




If anybody thinks I missed something or suspects that a different
wording would be better, feel free to make a suggestion.

Thanks.

Rich Sposato

---
[ 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.jamesd.demon.co.uk/csc/faq.html ]

Back to top
rich_sposato
Guest





PostPosted: Sun Aug 07, 2005 8:50 pm    Post subject: Re: Value of size parameter to operator [] not specified in Reply with quote



Correction:
Summary of this entry is:
Value of size parameter to operator [] not specified in standard.
It should be:
Value of size parameter to operator delete [] not specified in
standard.

---
[ 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.jamesd.demon.co.uk/csc/faq.html ]

Back to top
Marc Schoolderman
Guest





PostPosted: Sun Aug 07, 2005 9:32 pm    Post subject: Re: Value of size parameter to operator [] not specified in Reply with quote



rich_sposato wrote:

Quote:
I would like the ISO C++ Committee to make one small refinement to the
standard so that all compilers pass in the same size value to operator
delete [].

I think the paragraph you are looking for is 12.5/5. Seems to me you
found a bug in MSVC.

~Marc.

---
[ 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.jamesd.demon.co.uk/csc/faq.html ]


Back to top
rich_sposato
Guest





PostPosted: Mon Aug 08, 2005 6:12 am    Post subject: Re: Value of size parameter to operator [] not specified in Reply with quote

Marc wrote:
Quote:
I think the paragraph you are looking for is 12.5/5.
Got it. Thanks.


Quote:
Seems to me you found a bug in MSVC.
Yep, and that's not the only one I found in MSVC.


---
[ 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.jamesd.demon.co.uk/csc/faq.html ]


Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language, library and standards All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.