egcs-1.1a: new don't throw bad_alloc

Ryszard Kabatek rysio@rumcajs.chemie.uni-halle.de
Wed Sep 9 03:31:00 GMT 1998


I installed the egcs-1.1a (with static libs) into a 'egcs' directory.
I still have the gcc 2.7.2.3 and egcs-2.90.27 980315 (egcs-1.0.2 release).
My configuration:
Linux (RedHat 5.1), Pentium II
binutils 2.9.1.0.4

The operator new don't throw bad_alloc if the allocation fails.

eg++ main.cc
a.out
Segmentation fault (core dumped).

// main.cc
# include <iostream.h>
# include <exception>

int main()
{
  try {
     char* p = new char[4000000000UL];
     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




More information about the Gcc mailing list