public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/100838] New: -fno-elide-constructors for C++14 missing required destructor call
@ 2021-05-30 20:37 kirshamir at gmail dot com
  2021-05-30 20:40 ` [Bug c++/100838] " kirshamir at gmail dot com
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: kirshamir at gmail dot com @ 2021-05-30 20:37 UTC (permalink / raw)
  To: gcc-bugs

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

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2022-05-13 18:24 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-30 20:37 [Bug c++/100838] New: -fno-elide-constructors for C++14 missing required destructor call kirshamir at gmail dot com
2021-05-30 20:40 ` [Bug c++/100838] " kirshamir at gmail dot com
2021-05-31  9:08 ` [Bug c++/100838] [11/12 Regression] -fno-elide-constructors for C++14 missing required destructor call since r11-5872-g4eb28483004f8291 marxin at gcc dot gnu.org
2021-05-31 14:49 ` jason at gcc dot gnu.org
2021-06-02 18:42 ` cvs-commit at gcc dot gnu.org
2021-06-09  0:47 ` [Bug c++/100838] [11 " jason at gcc dot gnu.org
2021-07-06  6:46 ` rguenth at gcc dot gnu.org
2021-07-09 20:14 ` cvs-commit at gcc dot gnu.org
2021-07-09 20:15 ` jason at gcc dot gnu.org
2022-04-14  0:22 ` cvs-commit at gcc dot gnu.org
2022-05-12 20:14 ` cvs-commit at gcc dot gnu.org
2022-05-12 21:24 ` cvs-commit at gcc dot gnu.org
2022-05-13 18:24 ` cvs-commit at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).