From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4870 invoked by alias); 10 Jul 2014 10:41:20 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 4500 invoked by uid 48); 10 Jul 2014 10:41:04 -0000 From: "theemathas at hotmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/61769] const reference value is changed to random by a range-for loop Date: Thu, 10 Jul 2014 10:41:00 -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: 4.8.2 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: theemathas at hotmail dot com X-Bugzilla-Status: RESOLVED 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: 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-SW-Source: 2014-07/txt/msg00629.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D61769 --- Comment #8 from theemathas at hotmail dot com --- (In reply to Jonathan Wakely from comment #7) > If you change it to: >=20 > const int& aa =3D std::abs(a); > const int& foo=3Dstd::max(aa, aa); >=20 > You'll see that the problem goes away because the value returned by std::= abs > gets its lifetime extended, then std::max returns a reference to the same > object, which has not gone out of scope. >=20 > Alternatively, avoid the pointless reference: >=20 > int foo =3D std::max(std::abs(a), std::abs(a)); OK... I think I understand now. By the way, I managed to find the exact text in the standard that states th= at the code is invalid: http://stackoverflow.com/questions/2784262/does-a-const-reference-prolong-t= he-life-of-a-temporary "The lifetime extension is not transitive through a function argument. =C2= =A712.2/5 [class.temporary]: '...A temporary bound to a reference parameter in a func= tion call (=C2=A75.2.2 [expr.call]) persists until the completion of the full ex= pression containing the call.' " Thank you for explaining this, though. >>From gcc-bugs-return-456040-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Thu Jul 10 10:44:26 2014 Return-Path: Delivered-To: listarch-gcc-bugs@gcc.gnu.org Received: (qmail 9462 invoked by alias); 10 Jul 2014 10:44:25 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Delivered-To: mailing list gcc-bugs@gcc.gnu.org Received: (qmail 9381 invoked by uid 55); 10 Jul 2014 10:44:19 -0000 From: "ebotcazou at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/53590] compiler fails to generate SIMD instruction for FP division Date: Thu, 10 Jul 2014 10:44:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: 4.8.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: enhancement X-Bugzilla-Who: ebotcazou at gcc dot gnu.org X-Bugzilla-Status: RESOLVED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: ebotcazou at gcc dot gnu.org X-Bugzilla-Target-Milestone: 4.8.0 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2014-07/txt/msg00631.txt.bz2 Content-length: 645 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53590 --- Comment #15 from Eric Botcazou --- Author: ebotcazou Date: Thu Jul 10 10:43:46 2014 New Revision: 212426 URL: https://gcc.gnu.org/viewcvs?rev=212426&root=gcc&view=rev Log: PR middle-end/53590 * function.c (allocate_struct_function): Revert r188667 change. Added: branches/gcc-4_8-branch/gcc/testsuite/gnat.dg/opt39.adb - copied unchanged from r212425, trunk/gcc/testsuite/gnat.dg/opt39.adb Modified: branches/gcc-4_8-branch/gcc/ChangeLog branches/gcc-4_8-branch/gcc/function.c branches/gcc-4_8-branch/gcc/testsuite/ChangeLog