This is the mail archive of the gcc-bugs@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]

'throw' in new operator



Hi,

the following program causes 'Aborted (core dumped)':
---- cut -----
#include <iostream.h>
#include <stdlib.h>

void *operator new(size_t size)
{
  if(size>1000000)
    throw(10);
  return malloc(size);
}

int  main()
{
  try {
    char *buf=new char[1024*1024];
  }
  catch(int)
    {
      cerr <<"no enough memory\n";
      exit(-1);
    }
}
---- cut --------
rafal[1]:~/work/test/cc$ g++ --version
egcs-2.91.40
rafal[1]:~/work/test/cc$ g++ d.cc -o d
rafal[1]:~/work/test/cc$ ./d
Aborted (core dumped)

--
Rafal Lukawski mailto:rafal@gliwice.pl, voice: (+48) 602 266 876
System Administrator - dumb.iinf.polsl.gliwice.pl



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