This repository has been archived on 2024-12-16. You can view files and clone it, but cannot push or open issues or pull requests.
CodeBlocksPortable/WATCOM/samples/cppexamp/excarea/main.cpp

37 lines
715 B
C++

// EXCAREA main
//
// Throw and catch an 8K object to demonstrate that exceptions area
// has been extended.
#include <stdio.h>
struct object {
char array[ 8 * 1024 ];
};
int main()
{
int retn;
try {
object obj;
obj.array[0] = 'o';
obj.array[ sizeof( obj.array ) - 1 ] = 'k';
throw obj;
} catch( object const & ob ) {
if( ob.array[0] == 'o'
&& ob.array[ sizeof( ob.array ) - 1 ] == 'k' ) {
puts( "Passed\n" );
retn = 0;
} else {
puts( "FAILED: bad object\n" );
retn = 1;
}
} catch( ... ) {
puts( "FAILED to catch object\n" );
retn = 1;
}
return retn;
}