From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19151 invoked by alias); 12 Mar 2003 16:26: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 19130 invoked by uid 71); 12 Mar 2003 16:26:00 -0000 Resent-Date: 12 Mar 2003 16:26:00 -0000 Resent-Message-ID: <20030312162600.19129.qmail@sources.redhat.com> Resent-From: gcc-gnats@gcc.gnu.org (GNATS Filer) Resent-Cc: gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org Resent-Reply-To: gcc-gnats@gcc.gnu.org, peterson@austin.ibm.com Received: (qmail 18706 invoked by uid 48); 12 Mar 2003 16:21:42 -0000 Message-Id: <20030312162142.18705.qmail@sources.redhat.com> Date: Wed, 12 Mar 2003 16:26:00 -0000 From: peterson@austin.ibm.com Reply-To: peterson@austin.ibm.com To: gcc-gnats@gcc.gnu.org X-Send-Pr-Version: gnatsweb-2.9.3 (1.1.1.1.2.31) Subject: c/10040: Incorrect warning message for bit fields X-SW-Source: 2003-03/txt/msg00694.txt.bz2 List-Id: >Number: 10040 >Category: c >Synopsis: Incorrect warning message for bit fields >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: rejects-legal >Submitter-Id: net >Arrival-Date: Wed Mar 12 16:26:00 UTC 2003 >Closed-Date: >Last-Modified: >Originator: James Peterson, IBM Austin Research Lab >Release: 3.2.2 >Organization: >Environment: RedHat Linux 7.1 on AMD Athlon >Description: warning: comparison is always 0 due to width of bit-field message is generated because a 1 bit field is tested against one: int _v: 1; if ((*tlb)._hi._v == 1) This message comes from around line 3132 in fold-const.c where a comment says "the constant shifted right by the field length should be all zero", and then proceeds to create trees for (1 >> (lbitsize-1)) and see if the result is zero (or all ones). But lbitsize is 1, so lbitsize-1 is zero and this quantity is then (1 >> 0) which is still 1, and hence non-zero (but is all one's to the size of the bit field, so maybe the problem is integer_all_onesp). This code is followed by explicit code dealing with "single-bit compares". In trying to explain the problem, I'm beginning to see that this error message is a result of the bit field being an "int" (signed) rather than "unsigned int". In which case, maybe the problem is best addressed by a different warning message -- "bit field too small for value and sign bit; consider unsigned type for field" >How-To-Repeat: >Fix: >Release-Note: >Audit-Trail: >Unformatted: