public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "lisp2d at rambler dot ru" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/107132] New: a temporary object with an x-value is not destroyed and is bound to a variable Date: Mon, 03 Oct 2022 14:15:14 +0000 [thread overview] Message-ID: <bug-107132-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107132 Bug ID: 107132 Summary: a temporary object with an x-value is not destroyed and is bound to a variable Product: gcc Version: 12.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: lisp2d at rambler dot ru Target Milestone: --- a temporary object with an x-value is not destroyed and is bound to a variable the question is taken from a social network https://ru.stackoverflow.com/questions/1450260/Продление-времени-жизни-временного-объекта-в-присваивании/1450517#1450517 with tests https://godbolt.org/#z:OYLghAFBqd5QCxAYwPYBMCmBRdBLAF1QCcAaPECAMzwBtMA7AQwFtMQByARg9KtQYEAysib0QXACx8BBAKoBnTAAUAHpwAMvAFYTStJg1DIApACYAQuYukl9ZATwDKjdAGFUtAK4sGISQBspK4AMngMmAByPgBGmMQgAJykAA6oCoRODB7evv5BaRmOAmER0SxxCcl2mA5ZQgRMxAQ5Pn6Btpj2xQwNTQSlUbHxSbaNza15HQrjA%2BFDFSOJAJS2qF7EyOwc5gDM4cjeWADUJrtuTjPEmKxn2CYaAIIPj%2BEEx1hXXnUCCmdWTy%2BDmOj1OAHYLMcAH6PCDLY4MVCYVRbFLvEwQ06WayfAjEb49P67SEYgAi4NJ/xeLzexxYTHCcPBANBzJexw5xzQDBmIPMAWOTFOu3JzwhZOFooxVjBlOJ7M5M3QIBQ63R5zObixZlJmCBhOO4WOCjQKXYnI55jMwrcmo%2BerxBKyChtdrAOwArG4GO6qU8Lbj8T8eZLjho/ayyQqlSq0F51bbztrdfrncc1emqMbTeara6k4Gnb981rfV6fTt5U8yRxVrROB7eH4OFpSKhOLbsZZjetNpgsbseKQCJpa6sANb%2BRIAOkkc40AA4uBpEguwR6wbsgvWOJIm6O25xeAoQBph6PVnBYDBECBkbV4yRyJQmsAFMpDF0hAhUAB3ZtDmgLApHQTA9B%2BES0N%2Bf4AbwQEgfQCTAFwZhmKQ8F0PEADy8bQf%2BnBDveyCPMQb5HsEqi1A0%2BDNrw/CCCIYjsFIMiCIoKjqC2Oh6AYRgoNY1j6HgMQnpAqyoGizqcAAtEqZykqYXYWGYrYKL2Wx6Eq4QQV%2BP74dwvB4pg2xDr%2BxBMCkBG1voDb7lxh4cNglHII%2BxDHKoC4BNJASSMcwDIMgxwodO1oQJ2ViWKQxy4IQJADlwyyGReqwIDcWAJHCNm7rwLAgLsuzTokGiBIkuylQEGgelwVUeqQzatu2HDHqe55cZeN4QEgRGuc%2BECvu%2Bn5QXpsHoagwGgeBg14SNGGISgvHAAA%2Bo6DDjqN42IThwjDVZFG1CRZFNXtyDUeE5H0cIojiCxF3sWoB66GhC38UpQkifA4mSb8MlySKikRcpqnqcxYw0TpQ0wbtRkmbwZkWVZda2XVB6NU5D5EG5HleT5XILccEAreO8JhQJkXRfgGPxYlrVaMsKVpSMmU7nupC5YOs5gmYYJcFwARgpViQBLs0j1bwjXNWeI5taQV63t1GO9f14PTbts1gVkys7QZ60ISMABuyApCki161wiSLQYBAOotqg%2BTrmHEFtKva0RB0nkdRGnbRrGXUxEjSLdSj3fZui7PohjGKTNi0MJomZRJhKcAA9DG/3WCpx7A5pBBg1NWtDtDu1w5ZBmIxwjbI/ZqPOa57k4ywCgG8cpszpbDr4%2BFgnk7Fbl7AlSVtfTTDpZQZcs2zkjTgEqEeokkhlflHpmFItWiw5Es02OpCTh6GjTh6B%2BJFwC5FShkhmAEtU7rsdkNeRUu02XZi32L9/JaQevxBkziSEAA%3D #include <iostream> int destructions; struct A { ~A() noexcept { ++destructions; } }; int main() { { const A& a = A{} = A{}; std::cout << "Destructions in scope: " << destructions << '\n'; destructions = 0; } std::cout << "Destructions out of scope: " << destructions << '\n'; } the object under variable a should be dead. But it's still alive.
reply other threads:[~2022-10-03 14:15 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-107132-4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).