From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21001 invoked by alias); 7 Apr 2003 09:22:08 -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 20811 invoked from network); 7 Apr 2003 09:22:05 -0000 Received: from unknown (HELO ns2.uk.superh.com) (193.128.105.170) by sources.redhat.com with SMTP; 7 Apr 2003 09:22:05 -0000 Received: from sh-uk-ex01.uk.w2k.superh.com (sh-uk-ex01 [192.168.16.17]) by ns2.uk.superh.com (8.11.6+Sun/8.11.6) with ESMTP id h3791tx19841; Mon, 7 Apr 2003 10:01:55 +0100 (BST) content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-MimeOLE: Produced By Microsoft Exchange V6.0.5762.3 Subject: RE: memset (0, 0, 0); Date: Mon, 07 Apr 2003 09:22:00 -0000 Message-ID: <9FF3133289A7A84E81E2ED8F5E56B379604384@sh-uk-ex01.uk.w2k.superh.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: From: "Thomas,Stephen" To: "Andrew Cagney" , "Rennecke,Joern" Cc: , , , "McGoogan,Sean" X-SW-Source: 2003-04/txt/msg00059.txt.bz2 Hi, gdb appears to call memset(0,0,0) from build_regcache() in gdb/regcache.c. = I can't really claim to understand how this works, but this function appear= s to get called 3 times during gdb initialization: static void build_regcache (void) { ... int sizeof_register_valid; ... sizeof_register_valid =3D ((NUM_REGS + NUM_PSEUDO_REGS) * sizeof (*regi= ster_valid)); register_valid =3D xmalloc (sizeof_register_valid); memset (register_valid, 0, sizeof_register_valid); } On the 1st time of calling, none of the gdbarch stuff is set up, so NUM_REG= S =3D NUM_PSEUDO_REGS =3D 0. So xmalloc gets called with size=3D0. That ret= urns 0 as the 'address', which gets passed to memset. I guess this just wor= ks OK on other architectures (it does on x86 anyway). Easy enough to fix I suppose, but is that really the point? Steve Thomas SuperH (UK) Ltd. -----Original Message----- From: Andrew Cagney [mailto:ac131313@redhat.com]=20 Sent: 04 April 2003 16:17 To: Rennecke,Joern Cc: gdb@sources.redhat.com; newlib@sources.redhat.com; bug-glibc@gnu.org; T= homas,Stephen; McGoogan,Sean Subject: Re: memset (0, 0, 0); > This conflicts with gdb usage of memset (0, 0, 0); in some places.=20 > There are three practical questions here: > - should gdb use this idiom? > - should all target-specific variants of newlib's memset implement it? > - should all target-specific variants of glibc's memset implement it? I'm not sure why you're refering to GDB here. GDB assumes ISO C and=20 hence should never use memset in ways that violate the ISO C spec. If=20 it is, then someone gets to fix it. Andrew