[cfe-dev] RFC: do not optimize on basis of __attribute__((nonnull)) in glibc headers

Chandler Carruth via cfe-dev cfe-dev at lists.llvm.org
Tue Jan 3 15:23:02 PST 2017


On Tue, Jan 3, 2017 at 3:20 PM Richard Smith via cfe-dev <
cfe-dev at lists.llvm.org> wrote:

> The following glibc functions in <string.h> take both a pointer and a size
> providing an upper limit on the number of bytes that may be accessed
> through that pointer, and mark the pointer as __attribute__((nonnull)):
>
> ISO C:
>   memcpy, memmove, memset, memcmp, memchr, memrchr
>   strncpy [param 1 only], strncat [param 1 only], strncmp
>
> Extensions:
>   strndup, memccpy, mempcpy, strnlen, bcopy, bzero, bcmp, memfrob,
>   strncasecmp, strncasecmp_l [not parameter 4], stpncpy
>
> I would be interested in covering at least the ISO C functions. I don't
> have strong opinions about the extensions (any code built using those is
> likely also compiled with GCC, and so presumably has to fix this
> regardless).
>

I would argue strongly to cover bcopy, bzero, and bcmp at the very least.
These are BSD in origin and if anything I suspect there is *more* code at
risk of failure using those routines.

Looking at the list, I don't see any reason not to cover all of them.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20170103/95ccbaab/attachment.html>


More information about the cfe-dev mailing list