public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug analyzer/110426] New: Missing buffer overflow warning with function pointer that has the alloc_size attribute
@ 2023-06-27  4:18 alexhenrie24 at gmail dot com
  2023-06-28 15:54 ` [Bug analyzer/110426] " dmalcolm at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: alexhenrie24 at gmail dot com @ 2023-06-27  4:18 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 110426
           Summary: Missing buffer overflow warning with function pointer
                    that has the alloc_size attribute
           Product: gcc
           Version: 13.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: analyzer
          Assignee: dmalcolm at gcc dot gnu.org
          Reporter: alexhenrie24 at gmail dot com
  Target Milestone: ---

I expected to get a warning when compiling this program with -fanalyzer:

#include <stdlib.h>

extern void* (*my_alloc)(size_t) __attribute__ ((alloc_size (1)));

int main(void)
{
    int *x = my_alloc(1);
    x[0] = 0; // buffer overflow!
    return 0;
}

There is a warning if I call malloc instead of my_alloc.

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

end of thread, other threads:[~2023-08-16 19:25 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-27  4:18 [Bug analyzer/110426] New: Missing buffer overflow warning with function pointer that has the alloc_size attribute alexhenrie24 at gmail dot com
2023-06-28 15:54 ` [Bug analyzer/110426] " dmalcolm at gcc dot gnu.org
2023-08-04 20:20 ` cvs-commit at gcc dot gnu.org
2023-08-04 20:24 ` dmalcolm at gcc dot gnu.org
2023-08-16 19:25 ` alexhenrie24 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).