On Wed, 16 Nov 2016, Martin Sebor wrote:

On 11/16/2016 11:49 AM, Prathamesh Kulkarni wrote:
Hi Richard,
Following your suggestion in PR78154, the patch checks if stmt
contains call to memmove (and friends) in gimple_stmt_nonzero_warnv_p
and returns true in that case.

Nice.  I think the list should also include mempcpy, stpcpy, and
stpncpy, and probably also the corresponding checking built-ins
such as __builtin___memcpy_chk.

FWIW, a more general solution to consider (possibly for GCC 8)
might be to extend attribute nonnull to apply to a functions return
value as well (e.g., use zero as the index for that), to indicate
that a pointer returned from it is not null.  That would let library
implementers annotate other functions (such as strerror)

We already have that, under the name returns_nonnull. IIRC, people found a new name clearer than using position 0, when I posted the patch. Note also that memcpy already has both an attribute that says that it returns its first argument, and an attribute that says that said first argument is nonnull.

(I've heard some noise in C++-land about making memcpy(0,0,0) valid, but that may have just been noise)

--
Marc Glisse

Reply via email to