Ne.app NeANT
The Ne.app NeANT User module of the NeANT distribution.
NEW_OFLOW_SAFE.cpp
Go to the documentation of this file.
1// checking if operator new() checks the argument for overflow
2
3
25#include <stddef.h>
26
27#include "config.h"
28#include "nodbg.h"
29
30#if 2 == __GNUG__
31# ifndef _RWSTD_NO_HONOR_STD
32# ifdef _RWSTD_NO_STD_TERMINATE
33# include "terminate.h"
34# endif // _RWSTD_NO_STD_TERMINATE
35# endif // _RWSTD_NO_HONOR_STD
36#endif // gcc 2.x
37
38
39// 18.4.1.1
40// -3- Required behavior: Return a non-null pointer ... or else throw
41// a bad_alloc exception.
42
43int main ()
44{
45 nodbg ();
46
47 try {
48 void* p = ::operator new (size_t (-1));
49 }
50 catch (...) {
51 // exit successfully if new threw
52 return 0;
53 }
54
55 return 1;
56}
#define p
Definition 17.names.cpp:132
int main()
void nodbg()
Definition nodbg.h:52