On Mon, Sep 8, 2025 at 12:47 AM Chris Packham via Gcc <gcc@gcc.gnu.org> wrote: > > Hi GCC, > > For various reasons I find myself working with a few code bases that define > their own wrappers for memset(). Unfortunately these wrappers defeat gccs > ability to detect when the size of the pointer is passed instead of the > size of the pointed to object. > > Is there any attribute I can set on the memset like functions that will let > gcc know to perform the same kinds of checks as the standard memset > function?
There is not one for this specific warning. The code currently does a check on BUILT_IN_MEMSET in both the C and C++ front-ends. The calloc warning is based on "alloc_size" attribute though. So having a new attribute specifically for this kind of warning seems like a good idea. Can you file a bugzilla to add one that specifies the 2 arguments for memset ... Thanks, Andrew Pinski > > Thanks, > Chris