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

            Bug ID: 78666
           Summary: conflicting attribute alloc_size accepted
           Product: gcc
           Version: 7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: msebor at gcc dot gnu.org
  Target Milestone: ---

When attribute alloc_size is specified on two declarations of the same function
each time with a different argument number GCC doesn't issue any diagnostic but
instead disregards the second and subsequent attrribute specifications.  The
following test case show the problem.

GCC should instead issue a warning pointing out each occurrence of the
conflicting attribute and letting the user know with declaration it conflicts.

$ cat a.c && gcc -O2 -S -Wall -Wextra -Wpedantic a.c
void* f (int, int) __attribute__ ((alloc_size (1)));
void* f (int, int) __attribute__ ((alloc_size (2)));

int g (void)
{
  void *p = f (12, 34);
  return __builtin_object_size (p, 0);
}

Reply via email to