From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 126944 invoked by alias); 23 Oct 2019 17:41:58 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 126934 invoked by uid 89); 23 Oct 2019 17:41:58 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-2.3 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 spammy= X-HELO: gate.crashing.org Received: from gate.crashing.org (HELO gate.crashing.org) (63.228.1.57) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 23 Oct 2019 17:41:57 +0000 Received: from gate.crashing.org (localhost.localdomain [127.0.0.1]) by gate.crashing.org (8.14.1/8.14.1) with ESMTP id x9NHfXoG030891; Wed, 23 Oct 2019 12:41:33 -0500 Received: (from segher@localhost) by gate.crashing.org (8.14.1/8.14.1/Submit) id x9NHfWLm030889; Wed, 23 Oct 2019 12:41:32 -0500 Date: Wed, 23 Oct 2019 17:43:00 -0000 From: Segher Boessenkool To: Jakub Jelinek Cc: Alexander Monakov , Eduard-Mihai Burtescu , Ian Lance Taylor , gcc-patches , Ian Lance Taylor Subject: Re: [PATCH] Refactor rust-demangle to be independent of C++ demangling. Message-ID: <20191023174132.GQ28442@gate.crashing.org> References: <20191023163726.GO28442@gate.crashing.org> <20191023164614.GG2116@tucnak> <20191023171910.GP28442@gate.crashing.org> <20191023172848.GH2116@tucnak> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191023172848.GH2116@tucnak> User-Agent: Mutt/1.4.2.3i X-IsSubscribed: yes X-SW-Source: 2019-10/txt/msg01682.txt.bz2 On Wed, Oct 23, 2019 at 07:28:48PM +0200, Jakub Jelinek wrote: > On Wed, Oct 23, 2019 at 12:19:10PM -0500, Segher Boessenkool wrote: > > I of course know that for e.g. strcmp or strlen we need to be careful of > > page crossings; but this is strncmp, which has a size argument saying the > > size of the array objects of its arguments! > > https://pubs.opengroup.org/onlinepubs/009695399/functions/strncmp.html > The strncmp() function shall compare not more than n bytes > (bytes that follow a null byte are not compared) > from the array pointed to by s1 to the array pointed to by s2. > > In particular the second line. > > Similarly C11 7.24.4.4: > The strncmp function compares not more than n characters (characters that follow a > null character are not compared) from the array pointed to by s1 to the array pointed to > by s2. > > Similarly C99. Yes, and that does not say you cannot read more characters. It also does not say it compares the strings pointed to, it explicitly says characters from the array pointed to. Segher