From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26576 invoked by alias); 3 Jun 2009 21:36:38 -0000 Received: (qmail 26567 invoked by uid 22791); 3 Jun 2009 21:36:38 -0000 X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from sd-11162.dedibox.fr (HELO sd-11162.dedibox.fr) (88.191.70.230) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 03 Jun 2009 21:36:31 +0000 Received: from sd-11162.dedibox.fr (localhost.localdomain [127.0.0.1]) by sd-11162.dedibox.fr (Postfix) with ESMTP id 6BBDE92B91; Wed, 3 Jun 2009 23:36:29 +0200 (CEST) Received: from galileo (voyager.popies.net [81.56.254.183]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by sd-11162.dedibox.fr (Postfix) with ESMTPSA id 0AE9E92B82; Wed, 3 Jun 2009 23:36:29 +0200 (CEST) Received: by galileo (Postfix, from userid 1000) id D472BC1B3; Wed, 3 Jun 2009 23:36:25 +0200 (CEST) Date: Wed, 03 Jun 2009 21:36:00 -0000 From: Stelian Pop To: Ian Lance Taylor Cc: gcc@gcc.gnu.org Subject: Re: Problem with init of structure bit fields Message-ID: <20090603213624.GB11398@galileo> Reply-To: Stelian Pop References: <20090603174929.GA28130@sd-11162.dedibox.fr> <20090603193204.GA11398@galileo> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.18 (2008-05-17) X-AV-Checked: ClamAV using ClamSMTP X-IsSubscribed: yes Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org X-SW-Source: 2009-06/txt/msg00052.txt.bz2 On Wed, Jun 03, 2009 at 01:07:08PM -0700, Ian Lance Taylor wrote: > > - unsigned int wordnum = (backwards ? nwords - i - 1 : i); > > + unsigned int wordnum = (backwards > > + ? GET_MODE_SIZE(fieldmode) / UNITS_PER_WORD > > + - i - 1 > > + : i); > > unsigned int bit_offset = (backwards > > ? MAX ((int) bitsize - ((int) i + 1) > > * BITS_PER_WORD, > > Your patch looks correct. However, it makes me wonder how the test case > passes on existing big-endian platforms, such as the PowerPC. Can you > explain how that works? I'm not sure, but it is related to the smaller word size on my platform and the size of the field (a 64 bit long long). The 991118-1.c test case passes ok on my platform when the word size is 32 or 16 bits (my processor has configurable word sizes). The only configuration that fails is when the word size is 8 bits... When I tried to simplify the testcase I obtained the simple assignment problem I posted in the original mail. And that problem was visible in both 8 and 16 bits configurations. So I suspect the problem won't be seen on PowerPC unless someone does TI or OI bit fields... -- Stelian Pop