11 # pragma warning( disable : 4700 )
13 # pragma warning( disable : 4756 )
15 # pragma warning( disable : 4127 )
18 #ifdef __INTEL_COMPILER
19 # pragma warning( disable : 592 )
23 # pragma clang diagnostic ignored "-Wuninitialized"
27 # pragma GCC diagnostic ignored "-Wuninitialized"
28 # if ( __GNUC__ > 4 ) || ( __GNUC__ == 4 && __GNUC_MINOR__ >= 7 )
29 # pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
33 #if __SUNPRO_CC >= 20800
34 # pragma error_messages (off,SEC_UNINITIALIZED_MEM_READ)
45 #if defined(_MSC_VER) || defined(__ICC)
46 #pragma optimize("", off)
62 fprintf(
ioQQQ,
" I will now div by 0 to get crash. Hold on.\n");
63 fprintf(
ioQQQ,
" If the next line says \"I am still alive - something is wrong ....\" then"
64 " there are problems.\n");
67 fprintf(
ioQQQ,
" I am still alive - something is wrong, result is %e\n",
73 else if( p.
nMatch(
"UNDE") )
77 fprintf(
ioQQQ,
" Now I will now use an undefined static variable. Hold on.\n");
78 fprintf(
ioQQQ,
" This should never fail since the compiler should have automatically"
79 " initialized it to zero.\n");
85 fprintf(
ioQQQ,
" I am still alive, this is the expected result. The "
86 "result of the multiplication of undefined by 1e-10 is "
92 double A_variable_which_SHOULD_be_used_uninitialized;
93 fprintf(
ioQQQ,
" Now I will now use an undefined variable off the stack. Hold on.\n");
94 fprintf(
ioQQQ,
" If the next line says \"I am still alive - something is wrong ....\" then"
95 " there are problems.\n");
98 A_variable_which_SHOULD_be_used_uninitialized *= 1e-10f;
101 fprintf(
ioQQQ,
" I am still alive - something is wrong, the result of the multiplication of"
102 " undefined by 1e-10 is %e\n", A_variable_which_SHOULD_be_used_uninitialized );
107 double *aa = (
double*)
MALLOC(3*
sizeof(
double));
108 fprintf(
ioQQQ,
" I will now use an undefined variable off the heap obtained with malloc."
112 fprintf(
ioQQQ,
" The malloc'ed memory was set to NaN.\n" );
114 fprintf(
ioQQQ,
" The malloc'ed memory was NOT initialized by MyMalloc.\n" );
115 fprintf(
ioQQQ,
" If the next line says \"I am still alive - something is wrong ....\" then"
116 " there are problems.\n");
121 fprintf(
ioQQQ,
" I am still alive - something is wrong, the result of the multiplication"
122 " of undefined by 1e-10 is %e\n", aa[1] );
133 fprintf(
ioQQQ,
" I will now make long overflow to get crash. Hold on.\n");
134 fprintf(
ioQQQ,
" If the next line says \"I am still alive - something is wrong ....\" then"
135 " there are problems.\n");
137 lng = (long)(
double(LONG_MAX)*sqrt(1e6));
138 fprintf(
ioQQQ,
" I am still alive - something is wrong, the result was %li\n",
144 else if( p.
nMatch(
"OVER") )
147 fprintf(
ioQQQ,
" I will now make floating point overflow to get crash. Hold on.\n");
148 fprintf(
ioQQQ,
" If the next line says \"I am still alive - something is wrong ....\" then"
149 " there are problems.\n");
152 fprintf(
ioQQQ,
" I am still alive - something is wrong, the result was %e\n",
158 else if( p.
nMatch(
"ASSE") )
160 fprintf(
ioQQQ,
" I will now assert that a false statement is true to get a crash.\n\n");
161 fprintf(
ioQQQ,
" The correct behavior is for the statement \"PROBLEM DISASTER An assert"
162 " has been thrown, this is bad\" to be printed, followed by lots more scary"
163 " looking messages.\n\n");
164 fprintf(
ioQQQ,
" If the next line says \"I am still alive - the assert macro is not working ....\" then"
165 " there are problems.\n\n");
168 fprintf(
ioQQQ,
" I am still alive - the assert macro is not working in this executable.\n");
173 else if( p.
nMatch(
" NAN") )
176 fprintf(
ioQQQ,
" I will now make invalid operation (div 0 by 0) to get crash. Hold on.\n");
177 fprintf(
ioQQQ,
" If the next line says \"I am still alive - something is wrong ....\" then"
178 " there are problems.\n");
181 fprintf(
ioQQQ,
" I am still alive - something is wrong, the result was %e\n",
190 fprintf(
ioQQQ,
" I will now initialize a float to a signaling NaN. This should never crash!\n");
192 fprintf(
ioQQQ,
" Initialization finished. I will now perform an operation on this variable."
194 fprintf(
ioQQQ,
" If the next line says \"I am still alive - something is wrong ....\" then"
195 " there are problems.\n");
198 fprintf(
ioQQQ,
" I am still alive - something is wrong, the result was %e\n",
204 else if( p.
nMatch(
"SETN") )
207 fprintf(
ioQQQ,
" I will now initialize a double to a signaling NaN. This should never crash!\n");
209 fprintf(
ioQQQ,
" Initialization finished. I will now perform an operation on this variable."
211 fprintf(
ioQQQ,
" If the next line says \"I am still alive - something is wrong ....\" then"
212 " there are problems.\n");
215 fprintf(
ioQQQ,
" I am still alive - something is wrong, the result was %e\n",
222 else if( p.
nMatch(
"BOUN") )
235 long int i = ( x >= 0. ) ? (
long)(x+0.5) +
ARR_SIZE : (long)(x-0.5);
240 fprintf(
ioQQQ,
" I will now access static array element ar2[%ld]. Hold on.\n", i );
241 fprintf(
ioQQQ,
" If the next line says \"I am still alive - something is wrong\" then"
242 " there are problems.\n");
246 fprintf(
ioQQQ,
" I am still alive - something is wrong\n" );
252 fprintf(
ioQQQ,
" I will now access automatic array element a[%ld]. Hold on.\n", i );
253 fprintf(
ioQQQ,
" If the next line says \"I am still alive - something is wrong\" then"
254 " there are problems.\n");
258 fprintf(
ioQQQ,
" I am still alive - something is wrong, return value was %.2e\n", a[i] );
261 else if( p.
nMatch(
"HEAP") )
265 fprintf(
ioQQQ,
" I will now access malloced heap array element ibound[%ld]. Hold on.\n", i );
266 fprintf(
ioQQQ,
" If the next line says \"I am still alive - something is wrong\" then"
267 " there are problems.\n");
270 fprintf(
ioQQQ,
" I am still alive - something is wrong, return value is %i\n" , ibound[i] );
274 else if( p.
nMatch(
"VECT") )
277 fprintf(
ioQQQ,
" I will now access vector array element ibound[%ld]. Hold on.\n", i );
278 fprintf(
ioQQQ,
" If the next line says \"I am still alive - something is wrong\" then"
279 " there are problems.\n");
282 fprintf(
ioQQQ,
" I am still alive - something is wrong, return value is %i\n" , ibound[i] );
285 else if( p.
nMatch(
"MULT") )
291 for(
int j=0; j < 3; j++ )
296 fprintf(
ioQQQ,
" I will now access multi_arr array element *b.ptr(0,%ld)."
298 fprintf(
ioQQQ,
" If the next line says \"I am still alive - something is wrong\" then"
299 " there are problems.\n\n");
303 fprintf(
ioQQQ,
" I am still alive - something is wrong, return value is %g\n", *p );
308 fprintf(
ioQQQ,
" I will now access multi_arr array element b[0][%ld]. Hold on.\n", i );
309 fprintf(
ioQQQ,
" If the next line says \"I am still alive - something is wrong\" then"
310 " there are problems.\n\n");
313 fprintf(
ioQQQ,
" I am still alive - something is wrong, return value is %g\n", b[0][i] );
318 else if( p.
nMatch(
"AVXP") )
321 fprintf(
ioQQQ,
" I will now access avx_ptr element ibound[%ld]. Hold on.\n", i );
322 fprintf(
ioQQQ,
" If the next line says \"I am still alive - something is wrong\" then"
323 " there are problems.\n");
326 fprintf(
ioQQQ,
" I am still alive - something is wrong, return value is %i\n" , ibound[i] );
331 fprintf(
ioQQQ,
" The CRASH BOUNDS command has five different tests. One must be specified\n" );
332 fprintf(
ioQQQ,
" The HEAP option tests a malloc/'d array - this tests valgrind or purify.\n");
333 fprintf(
ioQQQ,
" The STATIC option tests a static declared array, and the STACK or AUTO option"
334 " tests an automatic array - these test pgcc and g++.\n");
335 fprintf(
ioQQQ,
" The VECTOR option tests the STL container vector - this tests g++.\n");
336 fprintf(
ioQQQ,
" The MULTI option tests if bounds checking is enabled in the multi_arr class"
337 " (i.e., if the preprocessor macro BOUNDS_CHECK has been set).\n" );
338 fprintf(
ioQQQ,
" The AVXPTR option tests if bounds checking is enabled in the avx_ptr class.\n");
339 fprintf(
ioQQQ,
" All have a number as an optional argument, the array index to be accessed.\n");
346 else if( p.
nMatch(
"ISNA") )
351 fprintf(
ioQQQ,
" I will now set a float to SNaN. This should never crash!\n" );
353 fprintf(
ioQQQ,
" I will now test this variable with the isnan function\n" );
354 fprintf(
ioQQQ,
" The correct behavior is for the statement \"PROBLEM DISASTER An assert"
355 " has been thrown, this is bad\" to be printed, followed by lots more scary"
356 " looking messages.\n\n");
357 fprintf(
ioQQQ,
" If the next line says \"I am still alive - something is wrong\" then"
358 " there are problems.\n");
360 fprintf(
ioQQQ,
" I am still alive - something is wrong, value is %e\n", ff );
365 fprintf(
ioQQQ,
" I will now set a double to SNaN. This should never crash!\n" );
367 fprintf(
ioQQQ,
" I will now test this variable with the isnan function\n" );
368 fprintf(
ioQQQ,
" The correct behavior is for the statement \"PROBLEM DISASTER An assert"
369 " has been thrown, this is bad\" to be printed, followed by lots more scary"
370 " looking messages.\n\n");
371 fprintf(
ioQQQ,
" If the next line says \"I am still alive - something is wrong\" then"
372 " there are problems.\n");
374 fprintf(
ioQQQ,
" I am still alive - something is wrong, value is %e\n", dd );
379 else if( p.
nMatch(
"EXCE") )
381 fprintf(
ioQQQ,
" I will now throw a C++ exception of type out_of_range()\n" );
382 fprintf(
ioQQQ,
" The correct behavior is for the statement \"DISASTER - An out_of_range"
383 " exception was caught, what() = Cloudy Test. Bailing out...\" to be printed.\n\n");
384 fprintf(
ioQQQ,
" If you get any other message, the exception was not caught correctly.\n\n");
385 throw out_of_range(
"Cloudy Test" );
386 fprintf(
ioQQQ,
" If you see this statement, the exception did not terminate the program.\n" );
390 else if( p.
nMatch(
"DOMA") )
394 x1 = numeric_limits<double>().infinity();
395 x2 = numeric_limits<double>().quiet_NaN();
396 fprintf(
ioQQQ,
" I will now invoke vhypot() with invalid arguments.\n" );
397 fprintf(
ioQQQ,
" The correct behavior is for the statement \"DISASTER - A vectorized math"
398 " routine threw a domain_error. Bailing out...\" to be printed.\n\n" );
399 fprintf(
ioQQQ,
" If you get any other message, the exception was not caught correctly.\n\n");
400 vhypot(y,0.,0.,-1.,x1,3.,3.,x2,2.);
401 fprintf(
ioQQQ,
" If you see this statement, the exception did not terminate the program.\n" );
403 fprintf(
ioQQQ,
" AVX vectorization is not enabled, skipping crash test...\n" );
408 else if( p.
nMatch(
"INSA") )
411 " I will now call TotalInsanity(), which is used to report when an internal\n"
412 " inconsistency has been found & the code must exit.\n"
413 " The correct behavior is to print the following statement:\n\n"
414 " \"Something that cannot happen, has happened.\n"
415 " This is TotalInsanity, I live in service.cpp.\"\n\n"
416 " and exit reporting \"PROBLEM DISASTER\".\n"
417 " If the code continues, the TotalInsanity() function is broken.\n\n");
420 fprintf(
ioQQQ,
" If you see this statement, then TotalInsanity() did not terminate the program.\n" );
426 "Crash option not found - valid options are ZERO, UNDEfined, OVERflow, ASSErt,"
427 " _NAN, SETNan, BOUNds, ISNAn, EXCEption, DOMAin and INSAnity.\nSorry.\n");
bool nMatch(const char *chKey) const
NORETURN void TotalInsanity(void)
void set_NaN(sys_float &x)
void vhypot(const double x1[], const double x2[], double y[], long nlo, long nhi)
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
int fprintf(const Output &stream, const char *format,...)
static double ar2[ARR_SIZE]