From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19800 invoked by alias); 31 Mar 2003 05:17:13 -0000 Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org Received: (qmail 19793 invoked from network); 31 Mar 2003 05:17:12 -0000 Received: from unknown (HELO smtp1.euronet.nl) (194.134.35.133) by sources.redhat.com with SMTP; 31 Mar 2003 05:17:12 -0000 Received: from koffie.nl (rot2-p3309.dial.wanadoo.nl [62.234.207.237]) by smtp1.euronet.nl (Postfix) with ESMTP id 7EF9067145; Mon, 31 Mar 2003 07:17:03 +0200 (MEST) Message-ID: <3E87B155.3020408@koffie.nl> Date: Mon, 31 Mar 2003 08:46:00 -0000 From: Segher Boessenkool User-Agent: Mozilla/5.0 (Macintosh; U; PPC; en-US; rv:1.2.1) Gecko/20021130 X-Accept-Language: en MIME-Version: 1.0 To: Falk Hueffner Cc: gcc@gcc.gnu.org Subject: Re: long long bit-fields References: <87of3taur5.fsf@student.uni-tuebingen.de> In-Reply-To: <87of3taur5.fsf@student.uni-tuebingen.de> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-SW-Source: 2003-03/txt/msg01788.txt.bz2 Falk Hueffner wrote: > Hi, > > PR c/6346, middle-end/7018 and target/9620 deal with long long > bit-fields. I guess part of the confusion comes from the fact that the > C standard doesn't specify how they should behave (at least I couldn't > find it). So what is the following program supposed to print? > > #include > > int > main(int argc, char *argv[]){ > struct { > unsigned long long ull31a: 31; > unsigned long long ull31b: 31; > } x; > x.ull31a = -1; > x.ull31b = 1; > > printf("%016llx %016llx %016llx\n", > (x.ull31a << 48) >> 48, > (x.ull31a << 16), > (x.ull31b << 48)); > } > > Candidates are: > > ffffffffffffffff ffffffffffff0000 0000000000010000 (gcc) Correct (the integer promotions promote an unsigned integer bit-field to a signed integer, if it fits). > ffffffffffffffff 00007fffffff0000 0001000000000000 (Compaq C) Not correct. > 000000000000ffff 00007fffffff0000 0001000000000000 (g++) > 0000000000000000 ffffffffffff0000 0000000000000000 (Compaq C++) Don't know about C++, sorry. Segher