This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: egcs-1.1a: new don't not throw bad_alloc



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



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]