[cfe-dev] [LLVMdev] RFC: Adding attribute(nonnull) to things in libc++

Marshall Clow mclow.lists at gmail.com
Mon Jun 1 10:52:20 PDT 2015


On Mon, Jun 1, 2015 at 10:35 AM, Joerg Sonnenberger <joerg at britannica.bec.de
> wrote:

> On Mon, Jun 01, 2015 at 09:57:17AM -0700, Reid Kleckner wrote:
> > Why should memset / memcpy be attribute nonnull? Is there standardese
> that
> > supports that?
>
> The generic entry text of the standard section. IMO this is a standard
> bug and someone should *please* get it fixed. It is ridiculous that zero
> sized operations are considered UB.
>

That would require a change to the C standard, and, as far as I know, there
are no current plans to issue a revised C standard.

I *suppose* that we could change it in the C++ standard, but I doubt that
there would be any support on the committee for making std::memcpy
different from ::memcpy.

-- Marshall

P.S.   recent gcc (at least 4.8.x and later) make optimizations based on
this UB (i.e, if you pass a pointer to memcpy, then it can't be NULL).
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20150601/e42de28a/attachment.html>


More information about the cfe-dev mailing list