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"
36 #if defined(_MSC_VER) || defined(__ICC)
37 #pragma optimize("", off)
40 #elif defined(__HP_aCC)
55 fprintf(
ioQQQ,
" I will now div by 0 to get crash. Hold on.\n");
56 fprintf(
ioQQQ,
" If the next line says \"I am still alive - something is wrong ....\" then there are problems.\n");
59 fprintf(
ioQQQ,
" I am still alive - something is wrong, result is %e\n",
65 else if( p.
nMatch(
"UNDE") )
69 fprintf(
ioQQQ,
" Now I will now use an undefined static variable. Hold on.\n");
70 fprintf(
ioQQQ,
" This should never fail since the compiler should have automatically initialized it to zero.\n");
76 fprintf(
ioQQQ,
" I am still alive, this is the expected result. The "
77 "result of the multiplication of undefined by 1e-10 is "
83 double A_variable_which_SHOULD_be_used_uninitialized;
84 fprintf(
ioQQQ,
" Now I will now use an undefined variable off the stack. Hold on.\n");
85 fprintf(
ioQQQ,
" If the next line says \"I am still alive - something is wrong ....\" then there are problems.\n");
88 A_variable_which_SHOULD_be_used_uninitialized *= 1e-10f;
91 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 );
96 double *aa = (
double*)
MALLOC(3*
sizeof(
double));
97 fprintf(
ioQQQ,
" I will now use an undefined variable off the heap obtained with malloc. Hold on.\n");
100 fprintf(
ioQQQ,
" The malloc'ed memory was set to NaN.\n" );
102 fprintf(
ioQQQ,
" The malloc'ed memory was NOT initialized by MyMalloc.\n" );
103 fprintf(
ioQQQ,
" If the next line says \"I am still alive - something is wrong ....\" then there are problems.\n");
108 fprintf(
ioQQQ,
" I am still alive - something is wrong, the result of the multiplication of undefined by 1e-10 is %e\n", aa[1] );
119 fprintf(
ioQQQ,
" I will now make long overflow to get crash. Hold on.\n");
120 fprintf(
ioQQQ,
" If the next line says \"I am still alive - something is wrong ....\" then there are problems.\n");
122 lng = (long)(LONG_MAX*sqrt(1e6));
123 fprintf(
ioQQQ,
" I am still alive - something is wrong, the result was %li\n",
129 else if( p.
nMatch(
"OVER") )
132 fprintf(
ioQQQ,
" I will now make floating point overflow to get crash. Hold on.\n");
133 fprintf(
ioQQQ,
" If the next line says \"I am still alive - something is wrong ....\" then there are problems.\n");
136 fprintf(
ioQQQ,
" I am still alive - something is wrong, the result was %e\n",
142 else if( p.
nMatch(
"ASSE") )
144 fprintf(
ioQQQ,
" I will now assert that a false statement is true to get a crash.\n\n");
145 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");
146 fprintf(
ioQQQ,
" If the next line says \"I am still alive - the assert macro is not working ....\" then there are problems.\n\n");
149 fprintf(
ioQQQ,
" I am still alive - the assert macro is not working in this executable.\n");
154 else if( p.
nMatch(
" NAN") )
157 fprintf(
ioQQQ,
" I will now make invalid operation (div 0 by 0) to get crash. Hold on.\n");
158 fprintf(
ioQQQ,
" If the next line says \"I am still alive - something is wrong ....\" then there are problems.\n");
161 fprintf(
ioQQQ,
" I am still alive - something is wrong, the result was %e\n",
170 fprintf(
ioQQQ,
" I will now initialize a float to a signaling NaN. This should never crash!\n");
172 fprintf(
ioQQQ,
" Initialization finished. I will now perform an operation on this variable. Hold on.\n");
173 fprintf(
ioQQQ,
" If the next line says \"I am still alive - something is wrong ....\" then there are problems.\n");
176 fprintf(
ioQQQ,
" I am still alive - something is wrong, the result was %e\n",
182 else if( p.
nMatch(
"SETN") )
185 fprintf(
ioQQQ,
" I will now initialize a double to a signaling NaN. This should never crash!\n");
187 fprintf(
ioQQQ,
" Initialization finished. I will now perform an operation on this variable. Hold on.\n");
188 fprintf(
ioQQQ,
" If the next line says \"I am still alive - something is wrong ....\" then there are problems.\n");
191 fprintf(
ioQQQ,
" I am still alive - something is wrong, the result was %e\n",
198 else if( p.
nMatch(
"BOUN") )
211 long int i = ( x >= 0. ) ? (
long)(x+0.5) +
ARR_SIZE : (long)(x-0.5);
216 fprintf(
ioQQQ,
" I will now access static array element ar2[%ld]. Hold on.\n", i );
217 fprintf(
ioQQQ,
" If the next line says \"I am still alive - something is wrong\" then there are problems.\n");
221 fprintf(
ioQQQ,
" I am still alive - something is wrong\n" );
227 fprintf(
ioQQQ,
" I will now access automatic array element a[%ld]. Hold on.\n", i );
228 fprintf(
ioQQQ,
" If the next line says \"I am still alive - something is wrong\" then there are problems.\n");
232 fprintf(
ioQQQ,
" I am still alive - something is wrong, return value was %.2e\n", a[i] );
235 else if( p.
nMatch(
"HEAP") )
239 fprintf(
ioQQQ,
" I will now access malloced heap array element ibound[%ld]. Hold on.\n", i );
240 fprintf(
ioQQQ,
" If the next line says \"I am still alive - something is wrong\" then there are problems.\n");
243 fprintf(
ioQQQ,
" I am still alive - something is wrong, return value is %i\n" , ibound[i] );
247 else if( p.
nMatch(
"MULT") )
253 for(
int j=0; j < 3; j++ )
258 fprintf(
ioQQQ,
" I will now access multi_arr array element *b.ptr(0,%ld). Hold on.\n", i );
259 fprintf(
ioQQQ,
" If the next line says \"I am still alive - something is wrong\" then there are problems.\n\n");
263 fprintf(
ioQQQ,
" I am still alive - something is wrong, return value is %g\n", *p );
268 fprintf(
ioQQQ,
" I will now access multi_arr array element b[0][%ld]. Hold on.\n", i );
269 fprintf(
ioQQQ,
" If the next line says \"I am still alive - something is wrong\" then there are problems.\n\n");
272 fprintf(
ioQQQ,
" I am still alive - something is wrong, return value is %g\n" , b[0][i] );
279 fprintf(
ioQQQ,
" The CRASH BOUNDS command has four different tests. One must be specified\n" );
280 fprintf(
ioQQQ,
" The HEAP option tests a malloc/'d array - this tests valgrind or purify.\n");
281 fprintf(
ioQQQ,
" The STATIC option tests a static declared array, and the STACK or AUTO option tests an automatic array - these test pgcc.\n");
282 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" );
283 fprintf(
ioQQQ,
" All have a number as an optional argument, the array element to be accessed.\n");
290 else if( p.
nMatch(
"ISNA") )
295 fprintf(
ioQQQ,
" I will now set a float to SNaN. This should never crash!\n" );
297 fprintf(
ioQQQ,
" I will now test this variable with the isnan function\n" );
298 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");
299 fprintf(
ioQQQ,
" If the next line says \"I am still alive - something is wrong\" then there are problems.\n");
301 fprintf(
ioQQQ,
" I am still alive - something is wrong, value is %e\n", ff );
306 fprintf(
ioQQQ,
" I will now set a double to SNaN. This should never crash!\n" );
308 fprintf(
ioQQQ,
" I will now test this variable with the isnan function\n" );
309 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");
310 fprintf(
ioQQQ,
" If the next line says \"I am still alive - something is wrong\" then there are problems.\n");
312 fprintf(
ioQQQ,
" I am still alive - something is wrong, value is %e\n", dd );
317 else if( p.
nMatch(
"EXCE") )
319 fprintf(
ioQQQ,
" I will now throw a C++ exception of type out_of_range()\n" );
320 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");
321 fprintf(
ioQQQ,
" If you get any other message, the exception was not caught correctly.\n\n");
322 throw out_of_range(
"Cloudy Test" );
323 fprintf(
ioQQQ,
" If you see this statement, the exception did not terminate the program.\n" );
329 "Crash option not found - valid options are ZERO, UNDEfined,"
330 " OVERflow, ASSErt, _NAN, SETNan, BOUNds, ISNAn, and EXCEption.\nSorry.\n");
bool nMatch(const char *chKey) const
void set_NaN(sys_float &x)
void ParseCrashDo(Parser &p)
iterator ptr(size_type i1, size_type i2)
bool MyIsnan(const sys_float &x)
void reserve(size_type i1)
#define DEBUG_ENTRY(funcname)
multi_arr< double, 2 >::iterator md2i
static double ar2[ARR_SIZE]