https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103843
--- Comment #1 from Georgii.Shagov <georgii.sha...@be-tse.de> --- >From experiments, I would guess that in case of -O3 the call to destructor was substituted by initializer: This works fine: cat ./d.cpp #include <iostream> class S { public: S() : i{1} {} ~S() { i=0; } void foo() { this->~S(); } int getI() const { return i; } private: int i{0}; }; int main() { S s; do { std::cout << "Before foo: " << s.getI(); s.foo(); std::cout << "; After: " << s.getI() << std::endl; } while (false); return 0; } g++ ./d.cpp $./a.out Before foo: 1; After: 0 $g++ -O3 ./d.cpp $./a.out Before foo: 1; After: 0 g++ --version g++ (GCC) 10.2.1 20210130 (Red Hat 10.2.1-11)