Bug 12000 - incorrect default allocator for std::vector class template
Summary: incorrect default allocator for std::vector class template
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: libstdc++ (show other bugs)
Version: 3.3
: P2 normal
Target Milestone: 3.4.0
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-08-20 23:40 UTC by Boris Kolpackov
Modified: 2005-07-23 22:49 UTC (History)
1 user (show)

See Also:
Host: i386-gnu-linux
Target: i386-gnu-linux
Build: i386-gnu-linux
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Boris Kolpackov 2003-08-20 23:40:06 UTC
$ cat >vector_and_new.cpp

#include <vector>
#include <iostream>

using std::cerr;
using std::endl;

void*
operator new (std::size_t size) throw (std::bad_alloc)
{
  cerr << "new" << endl;

  return malloc (size);
}

void
operator delete (void* p) throw ()
{
  cerr << "delete " << endl;
  free (p);
}

int
main ()
{
  int* pi = new int;
  delete pi;

  std::vector<int> (1);
}

$ g++ --version
g++ (GCC) 3.3 (Debian)

$ g++ ./vector_and_new.cpp
$ ./a.out
new
delete
new
$
-------------------------
I believe this program should (at least) either print

new
delete

-or-

new
delete
new
delete
Comment 1 Andrew Pinski 2003-08-20 23:46:29 UTC
Actually this is a non bug, see libstdc++'s FAQ: <http://gcc.gnu.org/onlinedocs/libstdc++/faq/
index.html#4_4_leak>.