public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: peterson@austin.ibm.com
To: gcc-gnats@gcc.gnu.org
Subject: c/10040: Incorrect warning message for bit fields
Date: Wed, 12 Mar 2003 16:26:00 -0000	[thread overview]
Message-ID: <20030312162142.18705.qmail@sources.redhat.com> (raw)


>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:


             reply	other threads:[~2003-03-12 16:26 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-03-12 16:26 peterson [this message]
2003-03-12 16:45 nathan
2003-03-12 16:46 Falk Hueffner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20030312162142.18705.qmail@sources.redhat.com \
    --to=peterson@austin.ibm.com \
    --cc=gcc-gnats@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).