From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8074 invoked by alias); 25 Jun 2014 16:56:11 -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 8019 invoked by uid 48); 25 Jun 2014 16:56:07 -0000 From: "manu at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/61597] Unexpected behavior at runtime Date: Wed, 25 Jun 2014 16:56: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.9.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: manu at gcc dot gnu.org X-Bugzilla-Status: REOPENED 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 cf_reconfirmed_on cc resolution everconfirmed 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-06/txt/msg02012.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D61597 Manuel L=C3=B3pez-Ib=C3=A1=C3=B1ez changed: What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |REOPENED Last reconfirmed|2014-06-24 00:00:00 |2014-06-25 CC| |manu at gcc dot gnu.org Resolution|INVALID |--- Ever confirmed|0 |1 --- Comment #18 from Manuel L=C3=B3pez-Ib=C3=A1=C3=B1ez --- (In reply to Marc Glisse from comment #17) > And if func is inline, > it will require -fkeep-inline-functions. What is the difference between inline/not inline? > e.cc: In function 'Iter& func(Iter, int)': > e.cc:11:20: warning: function returns address of local variable > [-Wreturn-local-addr] > return iter +=3D n; > ^ Why it points to n? >>From gcc-bugs-return-454931-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Wed Jun 25 17:15:32 2014 Return-Path: Delivered-To: listarch-gcc-bugs@gcc.gnu.org Received: (qmail 24416 invoked by alias); 25 Jun 2014 17:15:31 -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 24344 invoked by uid 48); 25 Jun 2014 17:15:22 -0000 From: "mpolacek at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/61240] [4.8/4.9/4.10 Regression] Incorrect warning "integer overflow in expression" on pointer-pointer subtraction Date: Wed, 25 Jun 2014 17:15: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.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: mpolacek at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 4.8.4 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc 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-06/txt/msg02013.txt.bz2 Content-length: 1186 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61240 Marek Polacek changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |mpolacek at gcc dot gnu.org --- Comment #3 from Marek Polacek --- Richi, did you mean something like this? With this we wouldn't warn on nor p - (p - 1); neither q - (q - 1); line... --- a/gcc/c/c-typeck.c +++ b/gcc/c/c-typeck.c @@ -3513,6 +3513,9 @@ pointer_diff (location_t loc, tree op0, tree op1) { lit0 = TREE_OPERAND (con0, 1); con0 = TREE_OPERAND (con0, 0); + lit0 = convert (inttype, lit0); + if (TREE_CODE (lit0) == INTEGER_CST) + TREE_OVERFLOW (lit0) = 0; } else lit0 = integer_zero_node; @@ -3521,6 +3524,9 @@ pointer_diff (location_t loc, tree op0, tree op1) { lit1 = TREE_OPERAND (con1, 1); con1 = TREE_OPERAND (con1, 0); + lit1 = convert (inttype, lit1); + if (TREE_CODE (lit1) == INTEGER_CST) + TREE_OVERFLOW (lit1) = 0; } else lit1 = integer_zero_node;