public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "hjl.tools at gmail dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug driver/108196] New: Incorrect binary search in find_opt Date: Wed, 21 Dec 2022 20:10:22 +0000 [thread overview] Message-ID: <bug-108196-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108196 Bug ID: 108196 Summary: Incorrect binary search in find_opt Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: driver Assignee: unassigned at gcc dot gnu.org Reporter: hjl.tools at gmail dot com Target Milestone: --- opts-common.cc has /* Find mn such this lexicographical inequality holds: cl_options[mn] <= input < cl_options[mn + 1]. */ while (mx - mn > 1) { md = (mn + mx) / 2; opt_len = cl_options[md].opt_len; comp = strncmp (input, cl_options[md].opt_text + 1, opt_len); if (comp < 0) mx = md; else mn = md; } When md is the exact match, the search doesn't terminate and we may get the wrong result.
next reply other threads:[~2022-12-21 20:10 UTC|newest] Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-12-21 20:10 hjl.tools at gmail dot com [this message] 2022-12-21 20:20 ` [Bug driver/108196] " pinskia at gcc dot gnu.org 2022-12-21 20:31 ` hjl.tools at gmail dot com
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-108196-4@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: linkBe 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).