#include <iostream>
class A {
public:
A(bool call) __attribute__((optnone)) {
std::cout << "A() is constructed (this = " << static_cast<void*>(this) << ")\n";
weird();
}
~A() {
std::cout << "A() is destructed (this = " << static_cast<void*>(this) << ")\n";
}
void weird() {
hello();
}
virtual void hello() = 0;
};
void A::hello() {
std::cout << "Hello from A! (this = " << static_cast<void*>(this) << ")\n";
}
class B : public A {
public:
B(bool call ) : A(call) {
std::cout << "B() is constructed (this = " << static_cast<void*>(this) << ")\n";
hello();
}
~B() {
std::cout << "B() is destructed (this = " << static_cast<void*>(this) << ")\n";
}
virtual void hello();
};
void B::hello() {
std::cout << "Hello from B! (this = " << static_cast<void*>(this) << ")\n";
}
int main() {
//B not_call(false);
B call(true);
}
I2luY2x1ZGUgPGlvc3RyZWFtPgoKY2xhc3MgQSB7CiBwdWJsaWM6CiAgIEEoYm9vbCBjYWxsKSBfX2F0dHJpYnV0ZV9fKChvcHRub25lKSkgewogICAJc3RkOjpjb3V0IDw8ICJBKCkgaXMgY29uc3RydWN0ZWQgKHRoaXMgPSAiIDw8IHN0YXRpY19jYXN0PHZvaWQqPih0aGlzKSA8PCAiKVxuIjsKICAgCXdlaXJkKCk7CiAgIH0KICAgfkEoKSB7CiAgIAlzdGQ6OmNvdXQgPDwgIkEoKSBpcyBkZXN0cnVjdGVkICh0aGlzID0gIiA8PCBzdGF0aWNfY2FzdDx2b2lkKj4odGhpcykgPDwgIilcbiI7CiAgIH0KICAgdm9pZCB3ZWlyZCgpIHsKICAgICBoZWxsbygpOwogICB9CiAgIHZpcnR1YWwgdm9pZCBoZWxsbygpID0gMDsKfTsKCnZvaWQgQTo6aGVsbG8oKSB7CiAgc3RkOjpjb3V0IDw8ICJIZWxsbyBmcm9tIEEhICh0aGlzID0gIiA8PCBzdGF0aWNfY2FzdDx2b2lkKj4odGhpcykgPDwgIilcbiI7Cn0KCmNsYXNzIEIgOiBwdWJsaWMgQSB7CiBwdWJsaWM6CiAgIEIoYm9vbCBjYWxsICkgOiBBKGNhbG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