From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id EE9B63858012; Tue, 30 Mar 2021 20:09:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EE9B63858012 From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/99841] (temporary) refs Date: Tue, 30 Mar 2021 20:09:31 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: unknown X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: pinskia at gcc dot gnu.org X-Bugzilla-Status: RESOLVED X-Bugzilla-Resolution: INVALID X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_status resolution Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 30 Mar 2021 20:09:32 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D99841 Andrew Pinski changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |RESOLVED Resolution|--- |INVALID --- Comment #3 from Andrew Pinski --- (In reply to g.peterhoff from comment #2) > That is not the problem. I only made using type =3D ... and type(x) in the > ctor calls so that I can test different types. You like to throw that out= - > has no influence. I think you misunderstood. Take a look at: mm_pair_t m{type(1), type(2)}; there are two temps here created by type(1) and type(2). The lifetime of t= hose temps normally end at the end of the statement, unless they are extended du= e to the C++ rules of binding the temp to a reference. In this case they are not bound to a reference as the reference is not m but rather the constructor arguments (this is why mm_t works while the others don't). Adding -W -Wall -Werror to the command line we get the following warnings/errors: : In function 'int main()': :33:24: error: '' is used uninitialized [-Werror=3Duninitialized] 33 | std::cout << m.first << std::endl; | ^~~~~ :34:24: error: '' is used uninitialized [-Werror=3Duninitialized] 34 | std::cout << m.second << std::endl; | ^~~~~~ :39:35: error: '' is used uninitialized [-Werror=3Duninitialized] 39 | std::cout << std::get<0>(m) << std::endl; | ^ :40:35: error: '' is used uninitialized [-Werror=3Duninitialized] 40 | std::cout << std::get<1>(m) << std::endl; | ^ :45:24: error: '' is used uninitialized [-Werror=3Duninitialized] 45 | std::cout << m.min << std::endl; | ^~~ :46:24: error: '' is used uninitialized [-Werror=3Duninitialized] 46 | std::cout << m.max << std::endl; | ^~~ ----- CUT ---- Which is exactly what you expect when the temp rvalue does not gets its timeline extended past the end of that statement.=