From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3179 invoked by alias); 10 Apr 2003 14:46:01 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 3158 invoked by uid 71); 10 Apr 2003 14:46:01 -0000 Date: Thu, 10 Apr 2003 14:46:00 -0000 Message-ID: <20030410144601.3157.qmail@sources.redhat.com> To: nobody@gcc.gnu.org Cc: gcc-prs@gcc.gnu.org, From: Andreas Schwab Subject: Re: middle-end/7018: bitfield of type long long treated as int in shift Reply-To: Andreas Schwab X-SW-Source: 2003-04/txt/msg00448.txt.bz2 List-Id: The following reply was made to PR middle-end/7018; it has been noted by GNATS. From: Andreas Schwab To: "Christian Ehrhardt" Cc: gcc-gnats@gcc.gnu.org, jbeulich@novell.com, gcc-bugs@gcc.gnu.org, nobody@gcc.gnu.org, gcc-prs@gcc.gnu.org Subject: Re: middle-end/7018: bitfield of type long long treated as int in shift Date: Thu, 10 Apr 2003 16:44:20 +0200 "Christian Ehrhardt" writes: |> http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=7018 |> |> This PR is about this piece of code and it complains that the bitfield |> is promoted to int instead of unsigned long long in the return statement: |> |> struct s { |> unsigned long long uf:1; |> }; |> |> unsigned long long utest(const struct s*ps) { |> return ps->uf << 32; |> } |> |> IMHO this is behaviour is correct but the standard is somewhat vague |> wrt. bit-fields of other types than _Bool, char and int, so I need a |> language lawyer to make the final decision. |> |> The standard does state quite clearly that an unsigned int bitfield |> with a width less than that of int has to be promoted to int and not to |> unsigend int, i.e. there is no implicit conversion of the bitfield to |> its "container type". IMHO the integer conversion rank of this bitfield type (which has precision 1) is less than the rank of int, thus it is promoted to int. Andreas. -- Andreas Schwab, SuSE Labs, schwab@suse.de SuSE Linux AG, Deutschherrnstr. 15-19, D-90429 Nürnberg Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different."