9# pragma warning( disable : 4700 )
11# pragma warning( disable : 4756 )
13# pragma warning( disable : 4127 )
16#ifdef __INTEL_COMPILER
17# pragma warning( disable : 592 )
21# pragma clang diagnostic ignored "-Wuninitialized"
25# pragma GCC diagnostic ignored "-Wuninitialized"
26# if ( __GNUC__ > 4 ) || ( __GNUC__ == 4 && __GNUC_MINOR__ >= 7 )
27# pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
39#if defined(_MSC_VER) || defined(__ICC)
40#pragma optimize("", off)
43#elif defined(__HP_aCC)
58 fprintf(
ioQQQ,
" I will now div by 0 to get crash. Hold on.\n");
59 fprintf(
ioQQQ,
" If the next line says \"I am still alive - something is wrong ....\" then there are problems.\n");
62 fprintf(
ioQQQ,
" I am still alive - something is wrong, result is %e\n",
68 else if( p.
nMatch(
"UNDE") )
72 fprintf(
ioQQQ,
" Now I will now use an undefined static variable. Hold on.\n");
73 fprintf(
ioQQQ,
" This should never fail since the compiler should have automatically initialized it to zero.\n");
79 fprintf(
ioQQQ,
" I am still alive, this is the expected result. The "
80 "result of the multiplication of undefined by 1e-10 is "
86 double A_variable_which_SHOULD_be_used_uninitialized;
87 fprintf(
ioQQQ,
" Now I will now use an undefined variable off the stack. Hold on.\n");
88 fprintf(
ioQQQ,
" If the next line says \"I am still alive - something is wrong ....\" then there are problems.\n");
91 A_variable_which_SHOULD_be_used_uninitialized *= 1e-10f;
94 fprintf(
ioQQQ,
" I am still alive - something is wrong, the result of the multiplication of undefined by 1e-10 is %e\n", A_variable_which_SHOULD_be_used_uninitialized );
99 double *aa = (
double*)
MALLOC(3*
sizeof(
double));
100 fprintf(
ioQQQ,
" I will now use an undefined variable off the heap obtained with malloc. Hold on.\n");
103 fprintf(
ioQQQ,
" The malloc'ed memory was set to NaN.\n" );
105 fprintf(
ioQQQ,
" The malloc'ed memory was NOT initialized by MyMalloc.\n" );
106 fprintf(
ioQQQ,
" If the next line says \"I am still alive - something is wrong ....\" then there are problems.\n");
111 fprintf(
ioQQQ,
" I am still alive - something is wrong, the result of the multiplication of undefined by 1e-10 is %e\n", aa[1] );
122 fprintf(
ioQQQ,
" I will now make long overflow to get crash. Hold on.\n");
123 fprintf(
ioQQQ,
" If the next line says \"I am still alive - something is wrong ....\" then there are problems.\n");
125 lng = (long)(LONG_MAX*sqrt(1e6));
126 fprintf(
ioQQQ,
" I am still alive - something is wrong, the result was %li\n",
132 else if( p.
nMatch(
"OVER") )
135 fprintf(
ioQQQ,
" I will now make floating point overflow to get crash. Hold on.\n");
136 fprintf(
ioQQQ,
" If the next line says \"I am still alive - something is wrong ....\" then there are problems.\n");
139 fprintf(
ioQQQ,
" I am still alive - something is wrong, the result was %e\n",
145 else if( p.
nMatch(
"ASSE") )
147 fprintf(
ioQQQ,
" I will now assert that a false statement is true to get a crash.\n\n");
148 fprintf(
ioQQQ,
" The correct behavior is for the statement \"PROBLEM DISASTER An assert has been thrown, this is bad\" to be printed, followed by lots more scary looking messages.\n\n");
149 fprintf(
ioQQQ,
" If the next line says \"I am still alive - the assert macro is not working ....\" then there are problems.\n\n");
152 fprintf(
ioQQQ,
" I am still alive - the assert macro is not working in this executable.\n");
157 else if( p.
nMatch(
" NAN") )
160 fprintf(
ioQQQ,
" I will now make invalid operation (div 0 by 0) to get crash. Hold on.\n");
161 fprintf(
ioQQQ,
" If the next line says \"I am still alive - something is wrong ....\" then there are problems.\n");
164 fprintf(
ioQQQ,
" I am still alive - something is wrong, the result was %e\n",
173 fprintf(
ioQQQ,
" I will now initialize a float to a signaling NaN. This should never crash!\n");
175 fprintf(
ioQQQ,
" Initialization finished. I will now perform an operation on this variable. Hold on.\n");
176 fprintf(
ioQQQ,
" If the next line says \"I am still alive - something is wrong ....\" then there are problems.\n");
179 fprintf(
ioQQQ,
" I am still alive - something is wrong, the result was %e\n",
185 else if( p.
nMatch(
"SETN") )
188 fprintf(
ioQQQ,
" I will now initialize a double to a signaling NaN. This should never crash!\n");
190 fprintf(
ioQQQ,
" Initialization finished. I will now perform an operation on this variable. Hold on.\n");
191 fprintf(
ioQQQ,
" If the next line says \"I am still alive - something is wrong ....\" then there are problems.\n");
194 fprintf(
ioQQQ,
" I am still alive - something is wrong, the result was %e\n",
201 else if( p.
nMatch(
"BOUN") )
214 long int i = ( x >= 0. ) ? (
long)(x+0.5) +
ARR_SIZE : (long)(x-0.5);
219 fprintf(
ioQQQ,
" I will now access static array element ar2[%ld]. Hold on.\n", i );
220 fprintf(
ioQQQ,
" If the next line says \"I am still alive - something is wrong\" then there are problems.\n");
224 fprintf(
ioQQQ,
" I am still alive - something is wrong\n" );
230 fprintf(
ioQQQ,
" I will now access automatic array element a[%ld]. Hold on.\n", i );
231 fprintf(
ioQQQ,
" If the next line says \"I am still alive - something is wrong\" then there are problems.\n");
235 fprintf(
ioQQQ,
" I am still alive - something is wrong, return value was %.2e\n", a[i] );
238 else if( p.
nMatch(
"HEAP") )
242 fprintf(
ioQQQ,
" I will now access malloced heap array element ibound[%ld]. Hold on.\n", i );
243 fprintf(
ioQQQ,
" If the next line says \"I am still alive - something is wrong\" then there are problems.\n");
246 fprintf(
ioQQQ,
" I am still alive - something is wrong, return value is %i\n" , ibound[i] );
250 else if( p.
nMatch(
"MULT") )
256 for(
int j=0; j < 3; j++ )
261 fprintf(
ioQQQ,
" I will now access multi_arr array element *b.ptr(0,%ld). Hold on.\n", i );
262 fprintf(
ioQQQ,
" If the next line says \"I am still alive - something is wrong\" then there are problems.\n\n");
266 fprintf(
ioQQQ,
" I am still alive - something is wrong, return value is %g\n", *p );
271 fprintf(
ioQQQ,
" I will now access multi_arr array element b[0][%ld]. Hold on.\n", i );
272 fprintf(
ioQQQ,
" If the next line says \"I am still alive - something is wrong\" then there are problems.\n\n");
275 fprintf(
ioQQQ,
" I am still alive - something is wrong, return value is %g\n" , b[0][i] );
282 fprintf(
ioQQQ,
" The CRASH BOUNDS command has four different tests. One must be specified\n" );
283 fprintf(
ioQQQ,
" The HEAP option tests a malloc/'d array - this tests valgrind or purify.\n");
284 fprintf(
ioQQQ,
" The STATIC option tests a static declared array, and the STACK or AUTO option tests an automatic array - these test pgcc.\n");
285 fprintf(
ioQQQ,
" The MULTI option tests if bounds checking is enabled in the multi_arr class (i.e., if the preprocessor macro BOUNDS_CHECK has been set).\n" );
286 fprintf(
ioQQQ,
" All have a number as an optional argument, the array element to be accessed.\n");
293 else if( p.
nMatch(
"ISNA") )
298 fprintf(
ioQQQ,
" I will now set a float to SNaN. This should never crash!\n" );
300 fprintf(
ioQQQ,
" I will now test this variable with the isnan function\n" );
301 fprintf(
ioQQQ,
" The correct behavior is for the statement \"PROBLEM DISASTER An assert has been thrown, this is bad\" to be printed, followed by lots more scary looking messages.\n\n");
302 fprintf(
ioQQQ,
" If the next line says \"I am still alive - something is wrong\" then there are problems.\n");
304 fprintf(
ioQQQ,
" I am still alive - something is wrong, value is %e\n", ff );
309 fprintf(
ioQQQ,
" I will now set a double to SNaN. This should never crash!\n" );
311 fprintf(
ioQQQ,
" I will now test this variable with the isnan function\n" );
312 fprintf(
ioQQQ,
" The correct behavior is for the statement \"PROBLEM DISASTER An assert has been thrown, this is bad\" to be printed, followed by lots more scary looking messages.\n\n");
313 fprintf(
ioQQQ,
" If the next line says \"I am still alive - something is wrong\" then there are problems.\n");
315 fprintf(
ioQQQ,
" I am still alive - something is wrong, value is %e\n", dd );
320 else if( p.
nMatch(
"EXCE") )
322 fprintf(
ioQQQ,
" I will now throw a C++ exception of type out_of_range()\n" );
323 fprintf(
ioQQQ,
" The correct behavior is for the statement \"DISASTER - An out_of_range exception was caught, what() = Cloudy Test. Bailing out...\" to be printed.\n\n");
324 fprintf(
ioQQQ,
" If you get any other message, the exception was not caught correctly.\n\n");
325 throw out_of_range(
"Cloudy Test" );
326 fprintf(
ioQQQ,
" If you see this statement, the exception did not terminate the program.\n" );
332 "Crash option not found - valid options are ZERO, UNDEfined,"
333 " OVERflow, ASSErt, _NAN, SETNan, BOUNds, ISNAn, and EXCEption.\nSorry.\n");
#define DEBUG_ENTRY(funcname)
bool nMatch(const char *chKey) const
iterator ptr(size_type i1, size_type i2)
void reserve(size_type i1)
multi_arr< double, 2 >::iterator md2i
bool MyIsnan(const sys_float &x)
void set_NaN(sys_float &x)
static double ar2[ARR_SIZE]
void ParseCrashDo(Parser &p)