[llvm-dev] Which assumptions do llvm.memcpy/memmove/memset.* make when the count is 0?

John Regehr via llvm-dev llvm-dev at lists.llvm.org
Thu Jul 20 21:00:08 PDT 2017


> So, the pointer arguments of memcpy *shall* (a violation of a shall 
> clause is UB, per ยง4/2) have valid values, even though the function will 
> copy zero characters.

This is true in C but the question was about LLVM intrinsics.

Since the LangRef does not mention any such restriction, I would assume 
that memcpy(0,0,0) is not UB in LLVM.  If it is UB then we must update 
the LangRef to be clear on this point (actually we should update the 
LangRef either way since this is a question that'll come up again).

John



More information about the llvm-dev mailing list