This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: egcs-1.1a: new don't not throw bad_alloc
- To: egcs at cygnus dot com
- Subject: Re: egcs-1.1a: new don't not throw bad_alloc
- From: Ryszard Kabatek <rysio at rumcajs dot chemie dot uni-halle dot de>
- Date: Fri, 11 Sep 1998 12:13:37 +0200 (CEST)
I tested the behaviour of 'new' again.
If the size of the array is smaller then INT_MAX-11 (?),
'new' does throw bad_alloc.
If it's INT_MAX-10 or more 'new' does not throw.
My configuration:
Linux (RedHat 5.1), Pentium II
265 MB RAM
2x128MB swap
// sample.cc
# include <iostream.h>
# include <exception>
# include <climits>
int main()
{
try {
char* p = new char[INT_MAX-10];
p[1000] = 'x';
delete [] p;
}
catch (exception& exc) {
cerr << exc.what() << '\n';
}
}
Ryszard Kabatek
Martin-Luther University Halle-Wittenberg
Department of Physical Chemistry
Geusaer Str. 88, 06217 Merseburg, Germany
Tel. +49 3461 46 2487 Fax. +49 3461 46 2129
e-mail: kabatek@chemie.uni-halle.de