From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30557 invoked by alias); 13 Jun 2002 15:26:03 -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 30518 invoked by uid 71); 13 Jun 2002 15:26:01 -0000 Resent-Date: 13 Jun 2002 15:26:01 -0000 Resent-Message-ID: <20020613152601.30517.qmail@sources.redhat.com> Resent-From: gcc-gnats@gcc.gnu.org (GNATS Filer) Resent-To: nobody@gcc.gnu.org Resent-Cc: gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org Resent-Reply-To: gcc-gnats@gcc.gnu.org, jbeulich@novell.com Received: (qmail 20854 invoked by uid 61); 13 Jun 2002 15:17:17 -0000 Message-Id: <20020613151717.20852.qmail@sources.redhat.com> Date: Thu, 13 Jun 2002 08:26:00 -0000 From: jbeulich@novell.com Reply-To: jbeulich@novell.com To: gcc-gnats@gcc.gnu.org X-Send-Pr-Version: gnatsweb-2.9.3 (1.1.1.1.2.31) Subject: middle-end/7018: incorrect bitfield handling X-SW-Source: 2002-06/txt/msg00303.txt.bz2 List-Id: >Number: 7018 >Category: middle-end >Synopsis: incorrect bitfield handling >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: wrong-code >Submitter-Id: net >Arrival-Date: Thu Jun 13 08:26:01 PDT 2002 >Closed-Date: >Last-Modified: >Originator: Jan Beulich >Release: 3.1 >Organization: >Environment: cross compilers hosted on Cygwin (Win2K) >Description: The handling of bitfields where the type is wider than int, but the actual width is narrower than int is incorrect in that such bitfields are operated on as if they are ints. While certainly one can say that this is an extension anyway, having this inconsistent with the rest of the language doesn't seem to make sense (and the whole point of declaring a narrow bit field with a wide type is obviously to force the compiler to perform calculations with the wider precision), and the correction is simple. >How-To-Repeat: struct s { unsigned long long uf:1; }; unsigned long long utest(const struct s*ps) { return ps->uf << 32; } >Fix: In default_conversion, make the bit-field sub-clause convert the type to [unsigned] int only when the original type isn't wider, and use the wider type in the other cases. >Release-Note: >Audit-Trail: >Unformatted: