From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 156823856DCB; Mon, 7 Nov 2022 14:09:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 156823856DCB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1667830177; bh=VyGsFjYI5rclyUWoFw7bzcyumeQMgQX2wqbzTzdcEYQ=; h=From:To:Subject:Date:In-Reply-To:References:From; b=ry8Uf1PPtYGCA96GFN9iykvmoCS5LH+MS/oDzhQQnA5inL6yVSZhTYPlsm1M3h61V NeyiTYarPY2gqrY0qHWm8x2TFNAtO9X4tML+JpsqM9gxOJVXRvhhPY7jaMfh5rvhzw pLSqEjAnkNU3rm+LcrKfBYGDOzDjt1uUHBk3CV/s= From: "nik_1357 at mail dot ru" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/107554] Segmentation fault during GIMPLE pass: strlen (tree-ssa-strlen.cc:4772) Date: Mon, 07 Nov 2022 14:09:36 +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: 13.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: nik_1357 at mail dot ru X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D107554 --- Comment #1 from Nikita Voronov --- I debugged a little and found out that this bug is caused when size of obje= ct which has type of "long int" is being assigned to local variable of type "i= nt". Here's patch which fixed bug for me: diff --git a/gcc/tree-ssa-strlen.cc b/gcc/tree-ssa-strlen.cc index 5afbae1b72e..7789b792341 100644 --- a/gcc/tree-ssa-strlen.cc +++ b/gcc/tree-ssa-strlen.cc @@ -4735,7 +4735,7 @@ strlen_pass::count_nonzero_bytes (tree exp, gimple *s= tmt, /* Compute the number of leading nonzero bytes in the representation and update the minimum and maximum. */ - unsigned n =3D prep ? strnlen (prep, nbytes) : nbytes; + unsigned HOST_WIDE_INT n =3D prep ? strnlen (prep, nbytes) : nbytes; if (n < lenrange[0]) lenrange[0] =3D n;=