9 # pragma warning( disable : 4700 )
11 # pragma warning( disable : 4756 )
13 # pragma warning( disable : 4127 )
16 #ifdef __INTEL_COMPILER
17 # pragma warning( disable : 592 )
28 #if defined(_MSC_VER) || defined(__ICC)
29 #pragma optimize("", off)
32 #elif defined(__HP_aCC)
46 if(
nMatch(
"ZERO",chCard) )
48 fprintf(
ioQQQ,
" I will now div by 0 to get crash. Hold on.\n");
49 fprintf(
ioQQQ,
" If the next line says \"I am still alive - something is wrong ....\" then there are problems.\n");
52 fprintf(
ioQQQ,
" I am still alive - something is wrong, result is %e\n",
58 else if(
nMatch(
"UNDE",chCard) )
60 if(
nMatch(
"STAT",chCard) )
62 fprintf(
ioQQQ,
" Now I will now use an undefined static variable. Hold on.\n");
63 fprintf(
ioQQQ,
" This should never fail since the compiler should have automatically initialized it to zero.\n");
69 fprintf(
ioQQQ,
" I am still alive, this is the expected result. The "
70 "result of the multiplication of undefined by 1e-10 is "
74 else if(
nMatch(
"STAC",chCard) ||
nMatch(
"AUTO",chCard) )
76 double A_variable_which_SHOULD_be_used_uninitialized;
77 fprintf(
ioQQQ,
" Now I will now use an undefined variable off the stack. Hold on.\n");
78 fprintf(
ioQQQ,
" If the next line says \"I am still alive - something is wrong ....\" then there are problems.\n");
81 A_variable_which_SHOULD_be_used_uninitialized *= 1e-10f;
84 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 );
89 double *aa = (
double*)
MALLOC(3*
sizeof(
double));
90 fprintf(
ioQQQ,
" I will now use an undefined variable off the heap obtained with malloc. Hold on.\n");
93 fprintf(
ioQQQ,
" The malloc'ed memory was set to NaN.\n" );
95 fprintf(
ioQQQ,
" The malloc'ed memory was NOT initialized by MyMalloc.\n" );
96 fprintf(
ioQQQ,
" If the next line says \"I am still alive - something is wrong ....\" then there are problems.\n");
101 fprintf(
ioQQQ,
" I am still alive - something is wrong, the result of the multiplication of undefined by 1e-10 is %e\n", aa[1] );
109 else if(
nMatch(
"OVER",chCard) &&
nMatch(
"LONG",chCard) )
112 fprintf(
ioQQQ,
" I will now make long overflow to get crash. Hold on.\n");
113 fprintf(
ioQQQ,
" If the next line says \"I am still alive - something is wrong ....\" then there are problems.\n");
115 lng = (long)(LONG_MAX*sqrt(1e6));
116 fprintf(
ioQQQ,
" I am still alive - something is wrong, the result was %li\n",
122 else if(
nMatch(
"OVER",chCard) )
125 fprintf(
ioQQQ,
" I will now make floating point overflow to get crash. Hold on.\n");
126 fprintf(
ioQQQ,
" If the next line says \"I am still alive - something is wrong ....\" then there are problems.\n");
129 fprintf(
ioQQQ,
" I am still alive - something is wrong, the result was %e\n",
135 else if(
nMatch(
"ASSE",chCard) )
137 fprintf(
ioQQQ,
" I will now assert that a false statement is true to get a crash.\n\n");
138 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");
139 fprintf(
ioQQQ,
" If the next line says \"I am still alive - the assert macro is not working ....\" then there are problems.\n\n");
142 fprintf(
ioQQQ,
" I am still alive - the assert macro is not working in this executable.\n");
147 else if(
nMatch(
" NAN",chCard) )
150 fprintf(
ioQQQ,
" I will now make invalid operation (div 0 by 0) to get crash. Hold on.\n");
151 fprintf(
ioQQQ,
" If the next line says \"I am still alive - something is wrong ....\" then there are problems.\n");
154 fprintf(
ioQQQ,
" I am still alive - something is wrong, the result was %e\n",
160 else if(
nMatch(
"SETN",chCard) &&
nMatch(
"FLOA",chCard) )
163 fprintf(
ioQQQ,
" I will now initialize a float to a signaling NaN. This should never crash!\n");
165 fprintf(
ioQQQ,
" Initialization finished. I will now perform an operation on this variable. Hold on.\n");
166 fprintf(
ioQQQ,
" If the next line says \"I am still alive - something is wrong ....\" then there are problems.\n");
169 fprintf(
ioQQQ,
" I am still alive - something is wrong, the result was %e\n",
175 else if(
nMatch(
"SETN",chCard) )
178 fprintf(
ioQQQ,
" I will now initialize a double to a signaling NaN. This should never crash!\n");
180 fprintf(
ioQQQ,
" Initialization finished. I will now perform an operation on this variable. Hold on.\n");
181 fprintf(
ioQQQ,
" If the next line says \"I am still alive - something is wrong ....\" then there are problems.\n");
184 fprintf(
ioQQQ,
" I am still alive - something is wrong, the result was %e\n",
191 else if(
nMatch(
"BOUN",chCard) )
199 if( lgEOL &&
nMatch(
" LOW", chCard ) )
201 if( lgEOL &&
nMatch(
"HIGH", chCard ) )
206 i = ( x >= 0. ) ? (
long)(x+0.5) +
ARR_SIZE : (long)(x-0.5);
209 if(
nMatch(
"STAT",chCard) )
211 fprintf(
ioQQQ,
" I will now access static array element ar2[%ld]. Hold on.\n", i );
212 fprintf(
ioQQQ,
" If the next line says \"I am still alive - something is wrong\" then there are problems.\n");
216 fprintf(
ioQQQ,
" I am still alive - something is wrong\n" );
219 else if(
nMatch(
"STAC",chCard) ||
nMatch(
"AUTO",chCard) )
222 fprintf(
ioQQQ,
" I will now access automatic array element a[%ld]. Hold on.\n", i );
223 fprintf(
ioQQQ,
" If the next line says \"I am still alive - something is wrong\" then there are problems.\n");
227 fprintf(
ioQQQ,
" I am still alive - something is wrong, return value was %.2e\n", a[i] );
230 else if(
nMatch(
"HEAP",chCard) )
234 fprintf(
ioQQQ,
" I will now access malloced heap array element ibound[%ld]. Hold on.\n", i );
235 fprintf(
ioQQQ,
" If the next line says \"I am still alive - something is wrong\" then there are problems.\n");
238 fprintf(
ioQQQ,
" I am still alive - something is wrong, return value is %i\n" , ibound[i] );
242 else if(
nMatch(
"MULT",chCard) )
248 for(
int j=0; j < 3; j++ )
251 if(
nMatch(
"ITER",chCard) )
253 fprintf(
ioQQQ,
" I will now access multi_arr array element *b.ptr(0,%ld). Hold on.\n", i );
254 fprintf(
ioQQQ,
" If the next line says \"I am still alive - something is wrong\" then there are problems.\n\n");
258 fprintf(
ioQQQ,
" I am still alive - something is wrong, return value is %g\n", *p );
263 fprintf(
ioQQQ,
" I will now access multi_arr array element b[0][%ld]. Hold on.\n", i );
264 fprintf(
ioQQQ,
" If the next line says \"I am still alive - something is wrong\" then there are problems.\n\n");
267 fprintf(
ioQQQ,
" I am still alive - something is wrong, return value is %g\n" , b[0][i] );
274 fprintf(
ioQQQ,
" The CRASH BOUNDS command has four different tests. One must be specified\n" );
275 fprintf(
ioQQQ,
" The HEAP option tests a malloc/'d array - this tests valgrind or purify.\n");
276 fprintf(
ioQQQ,
" The STATIC option tests a static declared array, and the STACK or AUTO option tests an automatic array - these test pgcc.\n");
277 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" );
278 fprintf(
ioQQQ,
" All have a number as an optional argument, the array element to be accessed.\n");
285 else if(
nMatch(
"ISNA",chCard) )
287 if(
nMatch(
"FLOA",chCard) )
290 fprintf(
ioQQQ,
" I will now set a float to SNaN. This should never crash!\n" );
292 fprintf(
ioQQQ,
" I will now test this variable with the isnan function\n" );
293 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");
294 fprintf(
ioQQQ,
" If the next line says \"I am still alive - something is wrong\" then there are problems.\n");
296 fprintf(
ioQQQ,
" I am still alive - something is wrong, value is %e\n", ff );
301 fprintf(
ioQQQ,
" I will now set a double to SNaN. This should never crash!\n" );
303 fprintf(
ioQQQ,
" I will now test this variable with the isnan function\n" );
304 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");
305 fprintf(
ioQQQ,
" If the next line says \"I am still alive - something is wrong\" then there are problems.\n");
307 fprintf(
ioQQQ,
" I am still alive - something is wrong, value is %e\n", dd );
312 else if(
nMatch(
"EXCE",chCard) )
314 fprintf(
ioQQQ,
" I will now throw a C++ exception of type out_of_range()\n" );
315 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");
316 fprintf(
ioQQQ,
" If you get any other message, the exception was not caught correctly.\n\n");
317 throw out_of_range(
"Cloudy Test" );
318 fprintf(
ioQQQ,
" If you see this statement, the exception did not terminate the program.\n" );
324 "Crash option not found - valid options are ZERO, UNDEfined,"
325 " OVERflow, ASSErt, _NAN, SETNan, BOUNds, ISNAn, and EXCEption.\nSorry.\n");