slycelote / caide

Automates certain common tasks that you do during programming competitions
84 stars 18 forks source link

c++: Methods called from used destructors are removed #1

Closed slycelote closed 9 years ago

slycelote commented 9 years ago
/* Solution file */

class Test {
public:
        Test(int n) : n(n) {}
        ~Test() {
                print();
        }
        void print() {
                cout << n << endl;
        }
private:
        int n;
};

void solve(istream& in, ostream& out) {
        Test a(1000);
}

/* Submission.cpp: no method "Test::print()" that is called from destructor (destructor is not called explicitly, only by default on exit from function solve() )  */

class Test {
public:
        Test(int n) : n(n) {}
        ~Test() {
                print();
        }
private:
        int n;
};

void solve(istream& in, ostream& out) {
        Test a(1000);
}