Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: Andreas Schwab <schwab@suse.de>
To: Joern Rennecke <joern.rennecke@superh.com>
Cc: gdb@sources.redhat.com, newlib@sources.redhat.com,
	bug-glibc@gnu.org, stephen.thomas@superh.com,
	sean.mcgoogan@superh.com
Subject: Re: memset (0, 0, 0);
Date: Fri, 04 Apr 2003 15:21:00 -0000	[thread overview]
Message-ID: <je1y0iqoe3.fsf@sykes.suse.de> (raw)
In-Reply-To: <3E8D9C30.E2CA766E@superh.com> (Joern Rennecke's message of "Fri, 04 Apr 2003 15:52:32 +0100")

Joern Rennecke <joern.rennecke@superh.com> 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, schwab@suse.de
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."


  parent reply	other threads:[~2003-04-04 15:21 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-04-04 14:54 Joern Rennecke
2003-04-04 15:04 ` Daniel Jacobowitz
2003-04-04 15:16 ` Andrew Cagney
2003-04-04 15:21 ` Andreas Schwab [this message]
2003-04-04 16:12 Petr Vandrovec
2003-04-04 21:36 ` Andreas Schwab
2003-04-07  9:22 Thomas,Stephen
2003-04-07 13:07 ` Daniel Jacobowitz
2003-04-07 17:18 ` Geoff Keating
2003-04-08  7:52 Thomas,Stephen
2003-04-08 13:10 ` Richard Earnshaw
2003-04-08 13:26   ` Daniel Jacobowitz
2003-04-08 16:40     ` Richard Earnshaw
2003-04-08 20:51     ` Andrew Cagney
2003-04-08 17:57 ` Richard Earnshaw

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=je1y0iqoe3.fsf@sykes.suse.de \
    --to=schwab@suse.de \
    --cc=bug-glibc@gnu.org \
    --cc=gdb@sources.redhat.com \
    --cc=joern.rennecke@superh.com \
    --cc=newlib@sources.redhat.com \
    --cc=sean.mcgoogan@superh.com \
    --cc=stephen.thomas@superh.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox