[llvm-bugs] [Bug 50115] New: Can __builtin_memcpy be given a null pointer argument?

via llvm-bugs llvm-bugs at lists.llvm.org
Sat Apr 24 18:35:01 PDT 2021


https://bugs.llvm.org/show_bug.cgi?id=50115

            Bug ID: 50115
           Summary: Can __builtin_memcpy be given a null pointer argument?
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Documentation
          Assignee: unassignedclangbugs at nondot.org
          Reporter: davidfromonline at gmail.com
                CC: llvm-bugs at lists.llvm.org, richard-llvm at metafoo.co.uk

The C function memcpy cannot be given null pointers as arguments, even if the
size is 0. This is checked by UBSan.

It is unclear whether __builtin_memcpy has this same restriction. UBSan accepts
calls to __builtin_memcpy with null pointer arguments as long as the size is 0.
The documentation does not say whether this is guaranteed behavior.

I hope that it is defined to call it with null pointer arguments, since the
entire reason I'm using it is to avoid that check.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210425/f1b4037e/attachment.html>


More information about the llvm-bugs mailing list