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