[LLVMbugs] [Bug 18247] 3.4: memchr(NULL, '=', 0) is defined as NULL

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Dec 16 09:01:22 PST 2013


http://llvm.org/bugs/show_bug.cgi?id=18247

Jordan Rose <jordan_rose at apple.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |jordan_rose at apple.com
         Resolution|---                         |INVALID

--- Comment #1 from Jordan Rose <jordan_rose at apple.com> ---
This is actually invalid according to the C standard:

C11 7.24.1p2: Where an argument declared as "size_t n" specifies the length of
the array for a function, n can have the value zero on a call to that function.
Unless explicitly stated otherwise in the description of a particular function
in this subclause, pointer arguments on such a call shall still have valid
values, as described in 7.1.4. On such a call, a function that locates a
character finds no occurrence, a function that compares two character sequences
returns zero, and a function that copies characters copies zero characters.

C11 7.1.4p1: [...] If an argument to a function has an invalid value (such as
[...] a null pointer [...]) [...], the behavior is undefined.

The description of memchr (C11 7.24.5.1) doesn't mention that null pointers are
valid, so it's not safe to assume that they are on all platforms.

-- 
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/20131216/d06f32e6/attachment.html>


More information about the llvm-bugs mailing list