[llvm-dev] Is it time to allow StringRef to be constructed from nullptr?

Joerg Sonnenberger via llvm-dev llvm-dev at lists.llvm.org
Mon Sep 26 02:54:08 PDT 2016

On Sun, Sep 25, 2016 at 04:10:24PM +0000, Zachary Turner via llvm-dev wrote:
> 2) [nullptr, nullptr+0) is a valid range.  Why shouldn't we be able to
> construct a StringRef from an otherwise perfectly valid range?

The problem is that for a lot of functions, esp. the mem* family, NULL
as argument is triggering UB, even if size is 0. Since the GNU folks
started to attribute the functions like that, certain compilers will
pretty aggressively fold code based on that.


More information about the llvm-dev mailing list