From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25039 invoked by alias); 14 Apr 2011 19:29:07 -0000 Received: (qmail 25029 invoked by uid 22791); 14 Apr 2011 19:29:07 -0000 X-SWARE-Spam-Status: No, hits=-6.5 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 14 Apr 2011 19:28:58 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p3EJSuKT001473 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 14 Apr 2011 15:28:57 -0400 Received: from tyan-ft48-01.lab.bos.redhat.com (tyan-ft48-01.lab.bos.redhat.com [10.16.42.4]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p3EJSsNh022888 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 14 Apr 2011 15:28:55 -0400 Received: from tyan-ft48-01.lab.bos.redhat.com (localhost.localdomain [127.0.0.1]) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4) with ESMTP id p3EJSsNU032559; Thu, 14 Apr 2011 21:28:54 +0200 Received: (from jakub@localhost) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4/Submit) id p3EJSrUQ032557; Thu, 14 Apr 2011 21:28:53 +0200 Date: Thu, 14 Apr 2011 19:40:00 -0000 From: Jakub Jelinek To: Diego Novillo Cc: reply@codereview.appspotmail.com, rguenther@suse.de, gcc-patches@gcc.gnu.org Subject: Re: [lto/pph] Do not pack more bits than requested (issue4415044) Message-ID: <20110414192853.GR17079@tyan-ft48-01.lab.bos.redhat.com> Reply-To: Jakub Jelinek References: <20110414185053.6C532A00D@topo.tor.corp.google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20110414185053.6C532A00D@topo.tor.corp.google.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes 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 X-SW-Source: 2011-04/txt/msg01124.txt.bz2 On Thu, Apr 14, 2011 at 02:50:53PM -0400, Diego Novillo wrote: > @@ -1190,8 +1190,19 @@ bitpack_create (struct lto_output_stream *s) > static inline void > bp_pack_value (struct bitpack_d *bp, bitpack_word_t val, unsigned nbits) > { > - bitpack_word_t word = bp->word; > + bitpack_word_t mask, word; > int pos = bp->pos; > + > + word = bp->word; > + > + gcc_assert (nbits > 0 && nbits <= BITS_PER_BITPACK_WORD); > + > + /* Make sure that VAL only has the lower NBITS set. Generate a > + mask with the lower NBITS set and use it to filter the upper > + bits from VAL. */ > + mask = ((bitpack_word_t) 1 << nbits) - 1; If bitpack_word_t has BITS_PER_BITPACK_WORD bits, then for nbits = BITS_PER_BITPACK_WORD this will be undefined. Use say mask = ((bitpack_word_t) 2 << (nbits - 1)) - 1; or something similar (assertion ensures that nbits isn't 0). Jakub