[PATCH] handle function pointers in __builtin_object_size (PR 88372)
Thu Dec 6 20:22:00 GMT 2018
Bug 88372 - alloc_size attribute is ignored on function pointers
points out that even though the alloc_size attribute is accepted
on function pointers it doesn't have any effect on Object Size
Checking. The reporter, who is implementing the feature in Clang,
wants to know if by exposing it under the same name they won't be
causing incompatibilities with GCC.
I don't think it's intentional that GCC doesn't take advantage of
the attribute for Object Size Checking, and certainly not to detect
the same kinds of issues as with other allocation functions (such
as excessive or negative size arguments). Rather, it's almost
certainly an oversight since GCC does make use of function pointer
attributes in other contexts (e.g., attributes alloc_align and
As an oversight, I think it's fair to consider it a bug rather
than a request for an enhancement. Since not handling
the attribute in Object Size Checking has adverse security
implications, I also think this bug should be addressed in GCC
9. With that, I submit the attached patch to resolve both
aspects of the problem.
Tested on x86_64-redhat-linux.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 14038 bytes
Desc: not available
More information about the Gcc-patches