Bruno Haible <[email protected]> writes:
> Do you mean to say that none of the functions
> memchr
> memcmp
> memcpy
> memmove
> memset
> wmemchr
> wmemcmp
> wmemcpy
> wmemmove
> wmemset
> may be called with arguments ptr = NULL and n = 0 ?
Yes. C99 7.2.21p2 says:
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.
7.1.4p1 says:
If an argument to a function has an invalid value (such as a
value outside the domain of the function, or a pointer
outside the address space of the program, or a null pointer,
or a pointer to non-modifiable storage when the
corresponding parameter is not const-qualified) or a type
(after promotion) not expected by a function with variable
number of arguments, the behavior is undefined.
In other words, 7.2.21 says that pointer arguments to these
functions must have valid values, and 7.1.4 says that null is an
invalid value.
--
"I don't want to learn the constitution and the declaration of
independence (marvelous poetry though it be) by heart, and worship the
flag and believe that there is a god and the dollar is its prophet."
--Maarten Wiltink in the Monastery
_______________________________________________
Bug-coreutils mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/bug-coreutils