public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug driver/108196] New: Incorrect binary search in find_opt
@ 2022-12-21 20:10 hjl.tools at gmail dot com
  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
  0 siblings, 2 replies; 3+ messages in thread
From: hjl.tools at gmail dot com @ 2022-12-21 20:10 UTC (permalink / raw)
  To: gcc-bugs

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.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug driver/108196] Incorrect binary search in find_opt
  2022-12-21 20:10 [Bug driver/108196] New: Incorrect binary search in find_opt hjl.tools at gmail dot com
@ 2022-12-21 20:20 ` pinskia at gcc dot gnu.org
  2022-12-21 20:31 ` hjl.tools at gmail dot com
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-12-21 20:20 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Can you give an example because this code has been there since
r0-51440-gcf03fd63cd7fd8 (since at least 3.4.0). And exact match has been
happening for a long time now.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug driver/108196] Incorrect binary search in find_opt
  2022-12-21 20:10 [Bug driver/108196] New: Incorrect binary search in find_opt hjl.tools at gmail dot com
  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
  1 sibling, 0 replies; 3+ messages in thread
From: hjl.tools at gmail dot com @ 2022-12-21 20:31 UTC (permalink / raw)
  To: gcc-bugs

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

H.J. Lu <hjl.tools at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |INVALID

--- Comment #2 from H.J. Lu <hjl.tools at gmail dot com> ---
It is a different issue.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-12-21 20:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-21 20:10 [Bug driver/108196] New: Incorrect binary search in find_opt hjl.tools at gmail dot com
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

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).