This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/88372] New: alloc_size attribute is ignored on function pointers


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

            Bug ID: 88372
           Summary: alloc_size attribute is ignored on function pointers
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: arichardson at FreeBSD dot org
  Target Milestone: ---

In the following example code __builtin_object_size does not return 100 when
used on result of a call to a function pointer. See
https://godbolt.org/z/MI5k_m :
```
void *malloc_function(int) __attribute__((alloc_size(1)));
void* (*malloc_function_pointer)(int) __attribute__((alloc_size(1))) =
malloc_function;

unsigned long int foo(void) {
  void *ptr = malloc_function_pointer(100);
  return __builtin_object_size(ptr, 0);
}

unsigned long int bar(void) {
  void *ptr = malloc_function(100);
  return __builtin_object_size(ptr, 0);
}
```

I have been working on supporting alloc_size on function pointers in clang
(https://reviews.llvm.org/D55212) and was wondering if GCC might also support
this in the future.
Is i acceptable if clang also accepts [[gnu::alloc_size(N)]] on function
pointers or would this be incompatible with potential future GCC changes?

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]