⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ctor15.c

📁 开放源码的编译器open watcom 1.6.0版的源代码
💻 C
字号:
#include "fail.h"

int count;

void die()
{
    if( --count <= 0 ) throw 1;
}

int ctors;

struct S {
    int v;
    S() { ++ctors; die(); }
    S(int x) : v(x) { ++ctors; die(); }
    ~S() { --ctors; if( ctors < 0 ) fail(__LINE__); }
};

void test( int n )
{
    count = n;
    S xx[5] = { 1, 2 };
}

void foo()
{
    for( int i = 0; i < 10; ++i ) {
	try {
	    test( i );
	} catch( int x ) {
	    if( x != 1 ) fail(__LINE__);
	} catch( ... ) {
	    fail(__LINE__);
	}
    }
}

int main()
{
    foo();
    _PASS;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -