From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id A00B9388E81F; Mon, 29 Jun 2020 09:35:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A00B9388E81F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1593423327; bh=iS6NVDg3+xLjVHFwlte7TVGKQuS5LlUfBc0kW0wd4dI=; h=From:To:Subject:Date:In-Reply-To:References:From; b=K+8NbxCtR5RKBJ1LAwKgpWK98mdNpaeabc2xTrCzrDIAKeCmMXZLKGeReds6vfOsX IzaVOrUUEjWTewfGERnGDvEa1OOXpZjJAf0lvcImZHKZ8fR7vgecLnQxE9MWx0ejW6 AQnR86/fA5xtQVQXpKAZu5LSkm6MDKiIc5UyM05s= From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/95903] gcc 10: wrong code with -fwrapv Date: Mon, 29 Jun 2020 09:35:23 +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: 10.1.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: jakub 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-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: Mon, 29 Jun 2020 09:35:27 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D95903 --- Comment #11 from CVS Commits --- The releases/gcc-10 branch has been updated by Jakub Jelinek : https://gcc.gnu.org/g:e29959c5fcd6c37b426c2939d7ba0c199b40d1ac commit r10-8384-ge29959c5fcd6c37b426c2939d7ba0c199b40d1ac Author: Jakub Jelinek Date: Sat Jun 27 12:38:23 2020 +0200 c-family: Use TYPE_OVERFLOW_UNDEFINED instead of !TYPE_UNSIGNED in pointer_sum [PR95903] For lp64 targets and int off ... ptr[off + 1] is lowered in pointer_sum to *(ptr + ((sizetype) off + (sizetype) 1)). That is fine when signed integer wrapping is undefined (and is not done already if off has unsigned type), but changes behavior for -fwrapv, wh= ere overflow is well defined. Runtime test could be: int main () { char *p =3D __builtin_malloc (0x100000000UL); if (!p) return 0; char *q =3D p + 0x80000000UL; int o =3D __INT_MAX__; q[o + 1] =3D 1; if (q[-__INT_MAX__ - 1] !=3D 1) __builtin_abort (); return 0; } with -fwrapv or so, not included in the testsuite because it requires 4= GB allocation (with some other test it would be enough to have something slightly above 2GB, but still...). 2020-06-27 Jakub Jelinek PR middle-end/95903 gcc/c-family/ * c-common.c (pointer_int_sum): Use TYPE_OVERFLOW_UNDEFINED ins= tead of !TYPE_UNSIGNED check to see if we can apply distributive law and handle smaller precision intop operands separately. gcc/testsuite/ * c-c++-common/pr95903.c: New test. (cherry picked from commit 37995960984ea2222346dd9d168d332cd6f7adf0)=