bug-glibc
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: memset (0, 0, 0);


From: Andreas Schwab
Subject: Re: memset (0, 0, 0);
Date: Fri, 04 Apr 2003 17:21:40 +0200
User-agent: Gnus/5.090017 (Oort Gnus v0.17) Emacs/21.3.50 (gnu/linux)

Joern Rennecke <address@hidden> writes:

|> So, as i understand this, this means that the first argument of memset
|> must point to an object, which contains at least one (the first)
|> character.  Passing a NULL pointer, or any other address which is
|> outside the address space of the program, invokes undefined behaviour.

IMHO 7.21.1[#2] gives the definitive answer:

    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.

7.21.6.1 (The memset function) does not say otherwise.

Andreas.

-- 
Andreas Schwab, SuSE Labs, address@hidden
SuSE Linux AG, Deutschherrnstr. 15-19, D-90429 N├╝rnberg
Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."




reply via email to

[Prev in Thread] Current Thread [Next in Thread]