Topic: operator delete sequencing
Author: Alberto Ganesh Barbati <AlbertoBarbati@libero.it>
Date: Fri, 29 Jun 2007 11:25:55 CST Raw View
Hi,
this is follow up of a post on comp.lang.c++.moderated. N2284 says in
[expr.delete] para 6 and 7 that a delete expression shall, on non-null
pointers:
1) call one or more destructors (if any)
2) call a deallocation function
In the original thread on comp.lang.c++.moderated it was noticed that
gcc in certain situations might reorder instructions so that some
side-effects of the execution of the destructor are actually applied
after the call to the allocation function. I believe that is a bug in gcc.
I am pretty sure that the intent is that the calls to the destructor or
destructors shall be sequenced before the call to the deallocation
function. If it were not so, then allocators such as the one described
in the thread (which is Bjarne Stroustroup's "pool allocator" example in
"The C++ Programming Language, Third Edition", Chapter 19) would be
impossible to implement portably.
However I could not find an explicit statement that guarantees that. Can
someone enlighten me? If there's no such statement, maybe [expr.delete]
para 7 could use a little clarification.
TIA,
Ganesh
---
[ 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 ]