From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id A744838582B7; Tue, 12 Mar 2024 09:24:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A744838582B7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1710235444; bh=gkbBzw5XSSrfCtEJAeCImqENPWbxA1ODTtbOBwI4qk8=; h=From:To:Subject:Date:In-Reply-To:References:From; b=bIvuIONfHRfhmdBeVvMmF7svMlYZlh06g5cHwrjruPRNvRHk1AZYd/Zf6IflE9oXH Vm0gZ8KazKGV9+v4HJKZQhB/I4PnydSkbzPTK6DQG5Z6fv9irBEnD2+/uuC/CcZPoi b78NxWmEF9yGjGKFztm9xehCnXG4gCqpVPcVlqwM= From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/114293] [14 Regression] ICE: in verify_range, at value-range.cc:1132 at -O2 Date: Tue, 12 Mar 2024 09:24:02 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: ice-on-valid-code, needs-bisection 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: 14.0 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D114293 --- Comment #3 from GCC Commits --- The master branch has been updated by Jakub Jelinek : https://gcc.gnu.org/g:39737cdf002637c7a652e9c3e36f369cfce581e5 commit r14-9437-g39737cdf002637c7a652e9c3e36f369cfce581e5 Author: Jakub Jelinek Date: Tue Mar 12 10:23:19 2024 +0100 strlen: Fix another spot that can create invalid ranges [PR114293] This PR is similar to PR110603 fixed with r14-8487, except in a differe= nt spot. From the memset with -1 size of non-zero value we determine mini= mum of (size_t) -1 and the code uses PTRDIFF_MAX - 2 (not really sure I understand why it is - 2 and not - 1, e.g. heap allocated array with PTRDIFF_MAX char elements which contain '\0' in the last element should be fine, no? One can still represent arr[PTRDIFF_MAX] - arr[0] and arr[0] - arr[PTRDIFF_MAX] in ptrdiff_t and strlen (arr) =3D=3D PTRDIFF_MAX - 1) as the maximum, so again invalid r= ange. As in the other case, it is just UB that can lead to that, and we have choice to only keep the min and use +inf for max, or only keep max and use 0 for min, or not set the range at all, or use [min, min] or [max, max] etc. The following patch uses [min, +inf]. 2024-03-12 Jakub Jelinek PR tree-optimization/114293 * tree-ssa-strlen.cc (strlen_pass::handle_builtin_strlen): If max is smaller than min, set max to ~(size_t)0. * gcc.dg/pr114293.c: New test.=