From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29288 invoked by alias); 4 Apr 2003 15:21:41 -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 29275 invoked from network); 4 Apr 2003 15:21:41 -0000 Received: from unknown (HELO Cantor.suse.de) (213.95.15.193) by sources.redhat.com with SMTP; 4 Apr 2003 15:21:41 -0000 Received: from Hermes.suse.de (Hermes.suse.de [213.95.15.136]) by Cantor.suse.de (Postfix) with ESMTP id 0411B1486C; Fri, 4 Apr 2003 17:21:41 +0200 (MEST) To: Joern Rennecke 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); X-Yow: UH-OH!! I put on ``GREAT HEAD-ON TRAIN COLLISIONS of the 50's'' by mistake!!! From: Andreas Schwab Date: Fri, 04 Apr 2003 15:21:00 -0000 In-Reply-To: <3E8D9C30.E2CA766E@superh.com> (Joern Rennecke's message of "Fri, 04 Apr 2003 15:52:32 +0100") Message-ID: User-Agent: Gnus/5.090017 (Oort Gnus v0.17) Emacs/21.3.50 (gnu/linux) References: <3E8D9C30.E2CA766E@superh.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-SW-Source: 2003-04/txt/msg00046.txt.bz2 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. 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."