public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/104854] New: [11 Regression] -Wstringop-overread should not warn for strnlen and strndup
@ 2022-03-09 14:24 siddhesh at gcc dot gnu.org
  2022-03-09 14:51 ` [Bug middle-end/104854] [11/12 " rguenth at gcc dot gnu.org
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: siddhesh at gcc dot gnu.org @ 2022-03-09 14:24 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 104854
           Summary: [11 Regression] -Wstringop-overread should not warn
                    for strnlen and strndup
           Product: gcc
           Version: 11.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: siddhesh at gcc dot gnu.org
  Target Milestone: ---

The only times that strnlen and strndup can result in an actual overread is:

- The source is zero sized

or 

- The source is not NULL terminated

In the current state something as trivial as the following:

char *
foo (size_t size)
{
  return __builtin_strndup ("test", size);
}

char *
bar (void)
{
  return foo (20);
}

issues a warning when the code is harmless.  This is probably better suited as
a static analysis heuristic/suggestion than as a compiler warning that tends to
 suggest that something is more likely wrong than not.

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

end of thread, other threads:[~2022-03-18 14:52 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-09 14:24 [Bug middle-end/104854] New: [11 Regression] -Wstringop-overread should not warn for strnlen and strndup siddhesh at gcc dot gnu.org
2022-03-09 14:51 ` [Bug middle-end/104854] [11/12 " rguenth at gcc dot gnu.org
2022-03-09 15:48 ` dmalcolm at gcc dot gnu.org
2022-03-09 16:05 ` siddhesh at gcc dot gnu.org
2022-03-09 22:32 ` [Bug middle-end/104854] " msebor at gcc dot gnu.org
2022-03-10  0:18 ` [Bug middle-end/104854] -Wstringop-overread should not warn for strnlen, strndup and strncmp siddhesh at gcc dot gnu.org
2022-03-14 17:51 ` msebor at gcc dot gnu.org
2022-03-14 19:13 ` siddhesh at gcc dot gnu.org
2022-03-14 20:58 ` msebor at gcc dot gnu.org
2022-03-15  5:16 ` siddhesh at gcc dot gnu.org
2022-03-17 12:47 ` dmalcolm at gcc dot gnu.org
2022-03-18 14:52 ` msebor at gcc dot gnu.org

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