From: "Petr Vandrovec" <VANDROVE@vc.cvut.cz>
To: Andreas Schwab <schwab@suse.de>
Cc: sean.mcgoogan@superh.com, bug-glibc@gnu.org,
stephen.thomas@superh.com, newlib@sources.redhat.com,
gdb@sources.redhat.com
Subject: Re: memset (0, 0, 0);
Date: Fri, 04 Apr 2003 16:12:00 -0000 [thread overview]
Message-ID: <68A3DC2781@vcnet.vc.cvut.cz> (raw)
On 4 Apr 03 at 17:21, Andreas Schwab wrote:
> 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.
But it is completely safe to call memset with unaligned pointer. Your
word read will do bad things in such situation (either you'll read memory
before object, or you'll read memory after object - first can cause
unexpected behavior, second can cause crash).
And it must not modify area outside of specified range, so please make sure
that
volatile unsigned int ptr;
memset(&ptr, 0, 0);
does not do any write at &ptr. I think that even reading from &ptr is
unexpected side effect...
BTW, all functions I know handle NULL, 0 without crash - being it
read, write, recvfrom (for both data & address), or current
implementation of memset, memcpy.
Petr Vandrovec
next reply other threads:[~2003-04-04 16:12 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-04-04 16:12 Petr Vandrovec [this message]
2003-04-04 21:36 ` Andreas Schwab
-- strict thread matches above, loose matches on Subject: below --
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
2003-04-07 9:22 Thomas,Stephen
2003-04-07 13:07 ` Daniel Jacobowitz
2003-04-07 17:18 ` Geoff Keating
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
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=68A3DC2781@vcnet.vc.cvut.cz \
--to=vandrove@vc.cvut.cz \
--cc=bug-glibc@gnu.org \
--cc=gdb@sources.redhat.com \
--cc=newlib@sources.redhat.com \
--cc=schwab@suse.de \
--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