hardly | b1e7e14 | 2014-08-06 00:43:51 +0300 | [diff] [blame] | 1 | // open a cmd and execute this: "C:\Program Files (x86)\Microsoft Visual Studio 11.0\vc\vcvarsall.bat" amd64
|
| 2 | // compile with:
|
| 3 | // cl.exe a.cpp /EHs
|
| 4 | // cl.exe a.cpp /EHa
|
| 5 |
|
| 6 | #ifdef _MSC_VER
|
| 7 | //#include <windows.h>
|
| 8 | #endif
|
| 9 |
|
| 10 | #include <iostream>
|
| 11 | using namespace std;
|
| 12 |
|
| 13 | void f(int argc, char** argv) {
|
| 14 | try {
|
| 15 | *((char*)666) = 1;
|
| 16 | } catch(...) {
|
| 17 | cout << "bad boy!" << endl;
|
| 18 | }
|
| 19 |
|
| 20 | try {
|
| 21 | int out = 5 / (argc - 1);
|
| 22 | cout << out;
|
| 23 | } catch(...) {
|
| 24 | cout << "bad boy!" << endl;
|
| 25 | }
|
| 26 | }
|
| 27 |
|
| 28 | int main(int argc, char** argv) {
|
| 29 |
|
| 30 | #ifdef _MSC_VER
|
| 31 | __try {
|
| 32 | #endif
|
| 33 |
|
| 34 | f(argc, argv);
|
| 35 |
|
| 36 | #ifdef _MSC_VER
|
| 37 | //} __except(EXCEPTION_EXECUTE_HANDLER) {
|
| 38 | } __except(1) {
|
| 39 | cout << "bad MS boy!" << endl;
|
| 40 | }
|
| 41 | #endif
|
| 42 |
|
| 43 | return 0;
|
| 44 | } |