dtor22.c

来自「开放源码的编译器open watcom 1.6.0版的源代码」· C语言 代码 · 共 36 行

C
36
字号
#include "fail.h"

int ctors;

struct CD {
    CD(int x = 0) : cond(x) {++ctors;};
    CD(CD const &s ) : cond(s.cond) {++ctors;};
    ~CD(){--ctors;};
    int cond;
};

CD ack()
{
    static int ctr;
    ++ctr;
    return CD(ctr);
}

#define LIMIT 4

int i;

int main() {
    {
	while( ( ack().cond / (LIMIT+2) ) < LIMIT ) {
	    while( ( ack().cond % (LIMIT+2) )  < LIMIT ) {
		++i;
	    }
	    ++i;
	}
    }
    if( ctors != 0 ) fail(__LINE__);
    if( ack().cond != 30 ) fail(__LINE__);
    _PASS;
}

⌨️ 快捷键说明

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