This is the mail archive of the
gcc-prs@gcc.gnu.org
mailing list for the GCC project.
libstdc++/9747: allocator<T>::deallocate(*, int ) does not call ::operator delete(size_t).
- From: axiong at ca dot ibm dot com
- To: gcc-gnats at gcc dot gnu dot org
- Date: 18 Feb 2003 19:35:18 -0000
- Subject: libstdc++/9747: allocator<T>::deallocate(*, int ) does not call ::operator delete(size_t).
- Reply-to: axiong at ca dot ibm dot com
>Number: 9747
>Category: libstdc++
>Synopsis: allocator<T>::deallocate(*, int ) does not call ::operator delete(size_t).
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Tue Feb 18 19:36:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator: Guan-Zhu (Andrew) Xiong
>Release: gcc version 3.2
>Organization:
>Environment:
Linux Version 2.4.19
SuSE SLES 8 (ppc) - Kernel 2.4.19-ul1-ppc64-SMP (16).
>Description:
=> allocator<T>::deallocate(*, int) does not call
::operator delete(size_t).
=> REF: ISO/IEC 14882:1998, 20.4.1.1 allocator members
=> WHAT: allocator<T>::deallocate(*, int) shall call
::operator delete(size_t). 20.4.1.1;10a (2)
=> The following C++ code shows that the ::operator
delete(size_t) is not called.
-> Expected Return Code from "main": 0
-> Actual Run Return Code from "main": 1
>How-To-Repeat:
1) Compile the given code "hello.C"
-> g++ -o hello hello.C
2) Run it
-> hello
3) get the return code from "main()"
- echo Return Code: $?
Then you will get: Return Code: 1. However, the expected
output sould be: Return Code: 0
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: text/plain; name="hello.C"
Content-Disposition: inline; filename="hello.C"
#include <memory>
#include <stdlib.h>
struct S {};
bool global = false;
template class std::allocator<S>; // explicit instantiation
void operator delete(void *p) throw()
{
global = true;
free(p);
}
int main(void)
{
std::allocator<S> a;
S* p = a.allocate(1);
a.deallocate(p,1);
if (!global) return 1;
return 0;
}