From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25401 invoked by alias); 4 Apr 2003 16:12:36 -0000 Mailing-List: contact gdb-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sources.redhat.com Received: (qmail 25383 invoked from network); 4 Apr 2003 16:12:34 -0000 Received: from unknown (HELO mailgw.cvut.cz) (147.32.3.235) by sources.redhat.com with SMTP; 4 Apr 2003 16:12:34 -0000 Received: from mailgw.cvut.cz (localhost [127.0.0.1]) by mailgw.cvut.cz (Postfix) with SMTP id A195A13B78D; Fri, 4 Apr 2003 18:12:33 +0200 (CEST) Received: from vcnet.vc.cvut.cz (vcnet.vc.cvut.cz [147.32.240.61]) by mailgw.cvut.cz (Postfix) with ESMTP id 6F61813B77D; Fri, 4 Apr 2003 18:12:33 +0200 (CEST) Received: from VCNET/SpoolDir by vcnet.vc.cvut.cz (Mercury 1.48); 4 Apr 03 18:12:30 +0100 Received: from SpoolDir by VCNET (Mercury 1.48); 4 Apr 03 18:12:29 +0100 From: "Petr Vandrovec" Organization: CC CTU Prague To: Andreas Schwab Date: Fri, 04 Apr 2003 16:12:00 -0000 MIME-Version: 1.0 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7BIT Subject: Re: memset (0, 0, 0); Cc: sean.mcgoogan@superh.com, bug-glibc@gnu.org, stephen.thomas@superh.com, newlib@sources.redhat.com, gdb@sources.redhat.com Priority: normal Message-ID: <68A3DC2781@vcnet.vc.cvut.cz> X-SW-Source: 2003-04/txt/msg00047.txt.bz2 On 4 Apr 03 at 17:21, Andreas Schwab wrote: > Joern Rennecke 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