public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "nik_1357 at mail dot ru" <gcc-bugzilla@gcc.gnu.org>
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	[thread overview]
Message-ID: <bug-107554-4-hQ1epPqHU7@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-107554-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107554

--- Comment #1 from Nikita Voronov <nik_1357 at mail dot ru> ---
I debugged a little and found out that this bug is caused when size of object
which has type of "long int" is being assigned to local variable of type "int".

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 *stmt,

   /* Compute the number of leading nonzero bytes in the representation
      and update the minimum and maximum.  */
-  unsigned n = prep ? strnlen (prep, nbytes) : nbytes;
+  unsigned HOST_WIDE_INT n = prep ? strnlen (prep, nbytes) : nbytes;

   if (n < lenrange[0])
     lenrange[0] = n;

  reply	other threads:[~2022-11-07 14:09 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-07 13:28 [Bug c/107554] New: " nik_1357 at mail dot ru
2022-11-07 14:09 ` nik_1357 at mail dot ru [this message]
2022-11-07 14:50 ` [Bug c/107554] " nik_1357 at mail dot ru
2022-11-07 16:51 ` [Bug tree-optimization/107554] [10/11/12/13 Regression] " pinskia at gcc dot gnu.org
2022-11-08  9:27 ` rguenth at gcc dot gnu.org
2022-11-11 13:28 ` rguenth at gcc dot gnu.org
2022-11-11 14:36 ` cvs-commit at gcc dot gnu.org
2022-11-11 15:41 ` [Bug tree-optimization/107554] [10/11/12 " jakub at gcc dot gnu.org
2023-01-24 14:27 ` cvs-commit at gcc dot gnu.org
2023-01-24 15:22 ` [Bug tree-optimization/107554] [10/11 " cvs-commit at gcc dot gnu.org
2023-01-26 13:05 ` [Bug tree-optimization/107554] [10 " cvs-commit at gcc dot gnu.org
2023-01-26 13:07 ` rguenth at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-107554-4-hQ1epPqHU7@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).