This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
libstdc++/8230: Buggy allocator behaviour
- From: gdr at nerim dot net
- To: gcc-gnats at gcc dot gnu dot org
- Cc: jkanze at caicheuvreux dot com, gdr at nerim dot net
- Date: 15 Oct 2002 12:48:09 -0000
- Subject: libstdc++/8230: Buggy allocator behaviour
- Reply-to: gdr at nerim dot net
>Number: 8230
>Category: libstdc++
>Synopsis: Buggy allocator behaviour
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Tue Oct 15 05:56:01 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator: James Kanze
>Release: all GCC releases.
>Organization:
>Environment:
Plateform independent, though the program below
displays the buggy behaviour on IA32.
>Description:
std:allocator<T>::allocate(n) does not check for possible
overflow before "folding" sizeof(T) * n.
>How-To-Repeat:
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: text/plain; name="jk.C"
Content-Disposition: inline; filename="jk.C"
#include <vector>
#include <iostream>
int main()
{
static size_t const size = 1024 * 1024 * 1024 ;
std::vector< int > array ;
try {
array.reserve( size ) ;
} catch ( std::exception const& error ) {
std::cerr << "Error: " << error.what() << " (type = " <<
typeid( error ).name() << ")\n" ;
return 2 ;
}
return 0 ;
}