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.
  • [Bug analyzer/110426] New: Miss... alexhenrie24 at gmail dot com via Gcc-bugs

Reply via email to