Re: memcpy( dest, src, 0 )
From: Dan Pop (Dan.Pop_at_cern.ch)
Date: 07/01/04
- Next message: Dan Pop: "Re: [OT] Re: memcpy() vs. for() performance"
- Previous message: Blue Ocean: "Why would anyone do this?"
- In reply to: Eric Sosman: "Re: memcpy( dest, src, 0 )"
- Next in thread: lawrence.jones_at_ugsplm.com: "Re: memcpy( dest, src, 0 )"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 1 Jul 2004 16:14:42 GMT
In <40E428E0.5020100@sun.com> Eric Sosman <Eric.Sosman@sun.com> writes:
>Peter Ammon wrote:
>> Eric Sosman wrote:
>>
>>> Spacen Jasset wrote:
>>>
>>>> given:
>>>>
>>>> memcpy( dest, src, 0 )
>>>>
>>>> What happens when the size paramater of memcpy is 0? Do the src and dest
>>>> have to be valid? It doesn't say anything about this in the standard
>>>> as far
>>>> as I can tell. So presumably they do have to be valid even when the
>>>> size is
>>>> 0.
>>>
>>> They must be valid. See section 7.1.4, paragraph 1. The
>>> general contract is that all arguments to library functions
>>> must be "real" unless the function's description explicitly
>>> permits "strange" arguments.
>>
>> Are there any examples of the latter?
>
> Others have pointed out some functions that accept NULL
>arguments. Here's a possibly odder example:
>
> char notstring[13] = "Hello, world!"; // no trailing zero
> printf ("%.6s strange new world!\n", notstring);
>
>The "%s" specifier usually takes an argument that points to
>the start of a zero-terminated C string, but when a precision
>is specified the argument need only point to the start of an
>array of `char', not necessarily zero-terminated.
I must be missing something. What is the chapter and verse from which
your example is an exception?!? What makes your example strange in any
way?
s If no l length modifier is present, the argument shall
be a pointer to the initial element of an array of
character type.
Dan
-- Dan Pop DESY Zeuthen, RZ group Email: Dan.Pop@ifh.de
- Next message: Dan Pop: "Re: [OT] Re: memcpy() vs. for() performance"
- Previous message: Blue Ocean: "Why would anyone do this?"
- In reply to: Eric Sosman: "Re: memcpy( dest, src, 0 )"
- Next in thread: lawrence.jones_at_ugsplm.com: "Re: memcpy( dest, src, 0 )"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|