Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:76694 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 69872 invoked from network); 19 Aug 2014 09:35:29 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 Aug 2014 09:35:29 -0000 Authentication-Results: pb1.pair.com header.from=pierre.php@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=pierre.php@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.216.51 as permitted sender) X-PHP-List-Original-Sender: pierre.php@gmail.com X-Host-Fingerprint: 209.85.216.51 mail-qa0-f51.google.com Received: from [209.85.216.51] ([209.85.216.51:56790] helo=mail-qa0-f51.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 63/13-55441-E5A13F35 for ; Tue, 19 Aug 2014 05:35:27 -0400 Received: by mail-qa0-f51.google.com with SMTP id k15so5354601qaq.38 for ; Tue, 19 Aug 2014 02:35:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=DsDaVHF2yPd2+VkYm/k0t5PeUvDzff0gZxuZK2YycM4=; b=uJXeyuNvT8tujn4xPTYerehyEq8OPnScWGlkQjFm/+TOwj7BmWp7sC2uIOyh7MBLxr 3tQcadGUydhAIMj8efBtnFs9KdC9G+ct3gbmfBJMAfTXYPKfVxAW8DRf5nvqepjYSgx/ LvzeVh5ighlaR6lo/kaTlJx5v58hu1FYDPenG7ttPJ0F9z7eUU2VA+KGdlDcSchCVdrh PFRVl44pzKtXCHEFQcXMtANNOr+eJF1G2JhnnZr9ioEdbYqTAd6ip1EZbI30I2KiGrnt 63fZ5ImTYX2rFLI6pl2RTm9H95QJ5cLbJirwOinqijU94fT6uYgLC7LmiEdhKsv25Emt WTjg== MIME-Version: 1.0 X-Received: by 10.224.119.193 with SMTP id a1mr15442544qar.18.1408440923960; Tue, 19 Aug 2014 02:35:23 -0700 (PDT) Received: by 10.140.95.146 with HTTP; Tue, 19 Aug 2014 02:35:23 -0700 (PDT) In-Reply-To: References: Date: Tue, 19 Aug 2014 11:35:23 +0200 Message-ID: To: Laruence Cc: Dmitry Stogov , Andi Gutmans , Nikita Popov , PHP internals Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] [VOTE] Abstract Syntax Tree From: pierre.php@gmail.com (Pierre Joye) On Tue, Aug 19, 2014 at 11:30 AM, Laruence wrote: > Hey: > > a fix could be: > diff --git a/Zend/zend_ast.c b/Zend/zend_ast.c > index eb35a51..f738e34 100644 > --- a/Zend/zend_ast.c > +++ b/Zend/zend_ast.c > @@ -33,11 +33,11 @@ static inline void *zend_ast_realloc(void *old, > size_t old_size, size_t new_size > return new; > } > > -size_t zend_ast_size(zend_uint children) { > +size_t zend_ast_size(int children) { > return sizeof(zend_ast) + sizeof(zend_ast *) * (children - 1); > } > > -size_t zend_ast_list_size(zend_uint children) { > +size_t zend_ast_list_size(int children) { > return sizeof(zend_ast_list) + sizeof(zend_ast *) * (children - 1); > } > > > my compiler must take (children -1) as a unsigned It does, the result of the expression will be. But the fix is imo wrong. A size cannot be negative, per se. It would be cleaner to do: size_t zend_ast_size(int children) { if (children > 0) { return sizeof(zend_ast) + sizeof(zend_ast *) * (children - 1); } else { // 0 or sizeof(zend_ast) + sizeof(zend_ast *) if at least one elem is allocated (NULLed). } } Cheers, -- Pierre @pierrejoye | http://www.libgd.org