https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100838
Bug ID: 100838 Summary: -fno-elide-constructors for C++14 missing required destructor call Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: kirshamir at gmail dot com Target Milestone: --- Code: https://godbolt.org/z/jKnKTds7s #include <iostream> class MyString { public: MyString(const char* s = "") { std::cout << "ctor" << std::endl; } ~MyString() { std::cout << "dtor" << std::endl; } MyString(const MyString& s) { std::cout << "copy ctor" << std::endl; } MyString& operator=(const MyString& s) { std::cout << "operator=" << std::endl; return *this; } }; int main() { MyString s1 = "Hello"; std::cout << __LINE__ << std::endl; } --------------- When compiled with: -std=c++14 -fno-elide-constructors Output: ctor copy ctor 22 dtor Expected output: ctor copy ctor dtor 22 dtor