From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4497 invoked by alias); 31 Oct 2013 16:52: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 4487 invoked by uid 89); 31 Oct 2013 16:52:57 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-wi0-f180.google.com Received: from mail-wi0-f180.google.com (HELO mail-wi0-f180.google.com) (209.85.212.180) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Thu, 31 Oct 2013 16:52:57 +0000 Received: by mail-wi0-f180.google.com with SMTP id ey11so3318022wid.1 for ; Thu, 31 Oct 2013 09:52:54 -0700 (PDT) X-Received: by 10.180.185.101 with SMTP id fb5mr267293wic.11.1383238373968; Thu, 31 Oct 2013 09:52:53 -0700 (PDT) MIME-Version: 1.0 Received: by 10.216.91.134 with HTTP; Thu, 31 Oct 2013 09:52:33 -0700 (PDT) In-Reply-To: <871u311ucp.fsf@redhat.com> References: <871u311ucp.fsf@redhat.com> From: =?ISO-8859-1?Q?Manuel_L=F3pez=2DIb=E1=F1ez?= Date: Thu, 31 Oct 2013 17:30:00 -0000 Message-ID: Subject: Re: [PATCH] preprocessor/58580 - preprocessor goes OOM with warning for zero literals To: Dodji Seketeli Cc: Tom Tromey , Jakub Jelinek , GCC Patches Content-Type: text/plain; charset=ISO-8859-1 X-SW-Source: 2013-10/txt/msg02714.txt.bz2 On 31 October 2013 05:46, Dodji Seketeli wrote: > +*/ > +static size_t > +string_length (const char* buf, size_t buf_size) > +{ > + for (int i = buf_size - 1; i > 0; --i) > + { > + if (buf[i] != 0) > + return i + 1; > + > + if (buf[i - 1] != 0) > + return i; > + } > + return 0; > +} Why do you check both buf[i] and buf[i - 1] within the loop? Cheers, Manuel.